GithubHelp home page GithubHelp logo

swaggerwcf's People

Contributors

abelsilva avatar chaasof avatar franky-li avatar jfdionne avatar justin0522 avatar kupferhirn avatar poulad avatar rozumak avatar sandycxt avatar squirmy avatar stojy avatar timsylvester avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swaggerwcf's Issues

Add Security to SwaggerWCF

Hi Abel,

Thanks for your library very useful. I have a question I need to add security to the initial call in swagger. Something like this.

image

I don't know, if it is possible with your package?
Kind regards,

Juan

Return type per HTTP status code?

[SwaggerWcfResponse(HttpStatusCode.OK, typeof(ClassA)]
[SwaggerWcfResponse(HttpStatusCode.BadRequest, typeof(ClassB)]

Is something similar possible?

Does this library support headers?

Is it possible to document, for example, the Apikey parameter being passed through in the header:
parameters:
- name: Apikey
in: header
description: API key
required: false
type: string
format: string
default: xxxx

Support multiple levels of complex types

a datacontract like this does not reflect the items collection:
public class ClientListResponse : ResponseBase<ClientList> { }

public class ResponseBase<T> { [DataMember] public T Body { get; set; } } public class ClientList { [DataMember] public List<ClientSummary> Clients { get; set; } }
The mapping helper adds the definition to the definitionsTypesList, but when these are built any complex type inside is not mapped.

French accent issue with version 0.1.18

Hi, with version 18 if we put accent, like "é" on SwaggerWcfPath it's doesn't show correctly, see my picture below at point #2

Another small issue, if we put accent on the SwaggerWcfTag we cannot click on the "get" section, it not expend, see point #1. I think it's because of the URL.

image

Problem in swagger output using empty Uri template

When I have a method like this:

    [OperationContract]
    [SwaggerWcfPath("Gets a set of translations", "Creates a translation")]
    [WebGet(
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = ""
        )]
    TranslationSet Get();

I see that it is shown in Swagger like this:

/gw/translations/Get

I did expect: /gw/translations to be the path. This is also the path i give to call this functionality.

likewise with Post:

How can I use swagger wcf to get or post on the main svc without sub path

SwaggerWcfTag hidefromspec seem to don't work

Hi,

the hidefromspeec on the SwaggerWcfTag seem to don't work.

I use it on my public interface like: (vb.net)

<SwaggerWcfTag("Test_Tag", True)>
<SwaggerWcfPath("Function small desc", "function full desc")>
<WebInvoke(Method:="GET", RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="/test/{id}")>
<OperationContract>
Function Test_function(id As Long) As boolean

the function still appear on my list, but if I put


on my web.config it's disappear.

thank you for all your work! very nice projet

Unused definitions generated for primitive types

Hello,

I have a method in my service that returns a long. In the YAML generated there is a definition for this type:

System.Int64:
    type: integer
    format: int64

But it is unused in the response of the operation:

responses:
     '200':
        description: Ok
        schema:
            type: integer
            format: int64

This causes a warning. How could I avoid this ?
Thank you

Please sign with a strong name key

Hi Abel, I'm interested in using SwaggerWcf for a commercial project, where we sign all our assemblies as part of a larger security scheme that we wouldn't wish to remove. At this time I am unable to even try SwaggerWcf out as I cannot build it into the project. Please consider signing the NuGet packaged assemblies (no need to expose your signing keys in the source tree) so people in my position are at least able to test ideas out :)

Many thanks,
Phil.

Support for task-async operations on the service.

Nice tool, just one little request:

the following method will expose the Task as the return type, where it should get the type of 'T' and reflect that.
[OperationContract] [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "Sample/", Method = "POST")] [SwaggerWcfPath("Sample", "Post a sample")] Task<SampleType> Sample(SampleType sampleMessage);

No provision for header values as parameters on the request.

Hi there,

I obtained your Swagger tool via NuGet, and managed to get it producing documentation as expected. However, I require all operations on my API to send a token in the header parameters. In addition to this is the requirement to send OAuth parameters in the headers too, however, I cannot see how to express this to your attributes.

From what I can see, it seems like its not implemented, however if it is, please could you tell me how to do it.

Many Thanks,
Alex

Double/decimal value (vb.net)

Hi, double or decimal value appear in Model of "Data Type" as a "number", but doesn't appear in "Model Schema".

Working with integer

swagger.json not being generated

Hello,
I have followed the Readme instructions correctly, I believe, but swagger.json is not being generated. In IIS, our WCF service is set up as an application under Default Web Site, with a virtual path of 'AbcWebService'

In global.asax, I have the following:
RouteTable.Routes.Add(new ServiceRoute("api-docs", new ServiceHostFactory(), typeof(SwaggerWcfEndpoint)));

test quote

When I navigate to 'http://localhost/AbcWebService/api-docs', I get a page containing:

SwaggerWcfEndpoint Service

You have created a service.

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://localhost/AbcWebService/api-docs?wsdl
...

Note that the above Route uses ServiceHostFactory instead of WebServiceHostFactory as specified in the instructions. But when I use the latter, I get a 404 with a The resource cannot be found. message when navigating to the api-docs URL listed above.

Can you please provide any assistance in troubleshooting this issue? I can provide the other modified files if desired - just let me know.

Thanks in advance.

Not able to work with https

I've been trying to create a swagger https endpoint on my wcf service with no success. Chrome allows me to navigate to the URI and enter credentials but shows an empty page. I can create an http endpoint with no issues, but as soon as I attempt to go https I get an empty page. I have a main https endpoint on port 8129 and am trying to get a swagger endpoint on port 8131 - i'm guess my config file isn't quite right. Any suggestions would be appreciated, my app.config is roughly:

<service name="SwaggerWcf.SwaggerWcfEndpoint">
    <endpoint address="docs" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint"
              behaviorConfiguration="swagger" bindingConfiguration="FileManagerBinding"/>
  <host>
    <baseAddresses>
      <add baseAddress="https://mycomputer:8131"/>
    </baseAddresses>
  </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServerServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" httpsGetUrl="" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Wti.Enterprise.Server.UserAuthentication,Wti.Enterprise.Server" />
        <!--       <clientCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust"/>
        </clientCertificate>
        <serviceCertificate findValue="123" storeLocation="LocalMachine"
                            storeName="My" x509FindType="FindByThumbprint"/> -->
      </serviceCredentials>
      <serviceAuthorization principalPermissionMode="Custom">
        <authorizationPolicies>
          <add policyType="Wti.Enterprise.Server.AuthorizationPolicy,Wti.Enterprise.Server" />
        </authorizationPolicies>
      </serviceAuthorization>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="MyEndpointBehavior">
      <!--
      <endpointDiscovery enabled="true">
      </endpointDiscovery> 
      -->
    </behavior>
    <behavior name="web">
      <webHttp />
    </behavior>
    <behavior name="web2">
      <webHttp />
    </behavior>
    <behavior name="swagger">
      <webHttp automaticFormatSelectionEnabled="true" />
    </behavior>
  </endpointBehaviors>
</behaviors>

</system.serviceModel>

Issues when publish the Service

I add the package properly to the project and in development work fine.

However. When I publish the build and deploy in one test server. I got errors like this.

image

What I have to do for deploy the swaggerWCF with the service.
Kind regards,

Define base URL

Hi, and thanks for this great work !

I was just wondering if there was a way to define the base URL of the project.
For instance, I've deployed my service on http://localhost/API/ but the docs considers it was deployed to http://localhost.

Thank you.

Stéphane S.

Lists are not processed properly

Swagger v0.1.10 from Nuget fails to generate "swagger.json" file in case if an operation contract's parameter is of list type and parameter's name cannot be found in an uri template.

Actually, I am not sure if it is right to check the presence of every parameter name in the uri at all because some request methods can take parameter's contents from body (for example, "POST").

I've created a separate repository with a solution to reproduce the issue: https://github.com/andriibratanin/SwaggerWcfBug

Security via OAuth

Hey together,
at first of all: Thank you so much for SwaggerWcf! It makes my work with wcf so much easier!

My Question/Issue:
Is it planned, to implement the oauth security definition of swagger 2.0? And if not: Can I help, to implement it? It's very important to me and I am able to help you out

Thank you so much!
René

No provision for header values as parameters on the request. SwaggerWcf

Hi Team,

I have implemented SwaggerWcf in my WCF service project via NuGet. It works. I need to send access token for my services in header parameters. But I don't know how to achieve this. Could you please help me on this?

If you can provide any working sample it will be appreciated. Many thanks.

Kind Regards
Senthil

path argument with default value wrongly interpreted as aparameter type body

WCF supports defining optional path variables (i.e. path variable with an optional argument), however this appears to be incorrectly interpreted as a 'body' parameter type instead of an optional 'path' parameter type. Also, the generated URL is incorrect.

MSDN refrence.. https://msdn.microsoft.com/en-us/library/bb675245(v=vs.110).aspx

Example..

        [WebGet(UriTemplate = "/race/{raceKey}/silks/{acceptorKey=null}?width={width}&height={height}", ResponseFormat = WebMessageFormat.Json)]
        Task<Stream> GetRaceSilks(string raceKey, string acceptorKey = null, string width = null, string height = null);

capture

Issues marked in red..

  1. wrong parameter type. should be type=path and string
  2. wrong generated url. should be http://localhost:30295/racing/race/1/silks?width=3&height=4 or http://localhost:30295/racing/race/1/silks/null?width=3&height=4

Support for BodyStyle = WebMessageBodyStyle.Wrapped in WebInvoke (post) methods

Hi Abel,

I think I've found a bug when using the WebMessageBodyStyle.Wrapped attribute on a WebInvoke method with multiple request parameters - the generated swagger path element contains multiple body parameters (illegal according to the specification) eg a method declared via an interface as:

        [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        bool CheckCredentials(
            string AccountName,
            string Password);

produces the following swagger declaration:

        "/TestService/CheckCredentials": {
            "post": {
                "operationId": "TestService.CheckCredentials",
                "consumes": ["application/json"],
                "produces": ["application/json"],
                "parameters": [{
                    "name": "AccountName",
                    "in": "body",
                    "required": true,
                    "schema": {
                        "$ref": "#/definitions/System.String"
                    }
                },
                {
                    "name": "Password",
                    "in": "body",
                    "required": true,
                    "schema": {
                        "$ref": "#/definitions/System.String"
                    }
                }],
...

I think (according to the scant information I can find on MSDN / StackOverflow) WCF expects the Wrapped attribute to implicitly generate a new object containing the multiple parameters as named fields: http://stackoverflow.com/questions/20206069/restful-web-service-body-format

Cheers,
Phil.

Modify the Swagger Landing Page.

Hi Abel,

I want to know. If it possible to change the templates and the configuration of Swagger in the package.

I look in the project and the templates for swagger seems to be locked inside the package. There is anyway that I can do this changing a property in the config file?

I want to achieve a more integrated swagger, online documentation using mds. I have a working example in java. But, I need to modify the templates of swagger for achieve that.

Could you give some hints for achieve this.

Kind regards,

Anyway to enable Swagger via HostFactory

I tried doing it the service way using config

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
  <serviceActivations>
    <add relativeAddress="api.svc" service="SwaggerWcf.SwaggerWcfEndpoint" factory="System.ServiceModel.Activation.ServiceHostFactory"/>
  </serviceActivations>
</serviceHostingEnvironment>

But all I get when routing to api.svc is a default Metadata publishing for this service is currently disabled page.

Create schemes manually using Tags

Hi Abel,

I need to add manually the model scheme for the response. The project do not have a DataContract associated because it is not necessary. I was checking the implementation and I think the Mapper.cs in Support is the one in charge of the retrospection in the object.

image

Currently, the schemes definition in the GetResponseCodes is getting null in my case no DataContract associated.

image

It is possible to add a new tag for Rest to emulate the DataContract and the DataMember or pass the scheme definition as a SwaggerTag?

image

image

I think if you guide I can implement that extra tag so, the implementation with REST calls without DataContract can be resolved too.

Thanks for your help.
Kind regards,
Juan

Host and Schemes attributes missing

Hello,

When you try swagger.json file with Microsoft Power Apps, it throws validation message for Host missing. I did fixed that in the code but you may want to apply that in the main branch.

Regards,
Kiran Chauhan

StaticContent not invoked

Hello, I'm triyng to add Swagger to my wcf service with Ninject, but have problem.

What I did with SwaggerWcf.Test.Service:

Install-Package Ninject.Extensions.Wcf

public class Global : NinjectHttpApplication
{
        protected override void OnApplicationStarted()
        {
            base.OnApplicationStarted();
            RegisterRoutes();
        }
        private void RegisterRoutes()
        {
            RouteTable.Routes.Add(new ServiceRoute("v1/rest", new NinjectServiceHostFactory(), typeof(BookStore)));
            RouteTable.Routes.Add(new ServiceRoute("api-docs", new NinjectServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
        }

        protected override IKernel CreateKernel()
        {
            return new StandardKernel(new ServiceModule());
        }
}
public class ServiceModule : WcfModule {}

At this point I get "Endpoint does not have a Binding with the None MessageVersion" for both http://localhost:52331/v1/rest and http://localhost:52331/api-docs

I add

    <services>
      <service name="SwaggerWcf.Test.Service.BookStore">
        <endpoint binding="webHttpBinding" contract="SwaggerWcf.Test.Service.IStore"  />
      </service>
      <service name="SwaggerWcf.SwaggerWcfEndpoint">
        <endpoint binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint" />        
      </service>
    </services>

This work with sample, but in my service http://localhost:52331/api-docs/index.html returns 404 because of WCF REST parameters cannot contain periods.

AutoRest Code Generator compatibility

Hi,

suggest to make sure generated swagger can be used as VS "REST API Client" generator installed as add-in with Azure SDK.
https://github.com/Azure/autorest/
preferably the initial version 0.9.6, since this one is still being distributed with Azure SDK although the tool is not Azure dependent/specific.

It looks like there are some compatibility issues, MS "AutoRest Code Generator" does not produce any output based on swagger output from your tool.

Output from MS recommended swagger tools https://github.com/domaindrivendev/Swashbuckle seems to be ok. However, is Web API tool, not WCF.
See: https://azure.microsoft.com/en-us/blog/announcing-the-azure-sdk-2-7-for-net/
"Positive Impacts of Template Swagger Tweaks for Client Developers" section.

Kind regards,

Tomasz

3d61edd8-0a17-11e6-8c40-25e842b3681d

change /swagger.json UriTemplate or allow it to be configurable

Hey Abel,
I came across your implementation of Swagger for WCF and have managed to get it working on our solution (we have a handrolled solution for documentation at the moment and need to move towards swagger).

The only issue I came across is that the SwaggerWcfEndpoint implementation uses “/swagger.json” as the UriTemplate and I finally realised that this was what was causing the swagger output to be inaccessible in our API.
As soon as I got your code running inside our solution and could debug through it I changed the URL to “/swagger” and it worked perfectly. (we actually can't access the UI component hosted at the other endpoint in ISwaggerWcfEndpoint.cs but don't need to use it so it's not causing an issue).

I believe this is down to how WCF routing can pick up specific urls or ignore others, I did find an article that semi explained it but I seem to have lost it.

So I’m just wondering whether this is something you would consider either changing (/swagger.json) or to allow it to be configurable by the user ( happy to try and solve this and do a PR)?

Incorrect InType when parameter name is part of the query

Consider the following example function:

        [OperationContract]
        [WebInvoke(UriTemplate = "patients/check", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Patient ApiCheckPatient(Patient patient);

As you can see "patient" is not a parameter in the Uri, but the text "patient" is partially contained, and, since Mapper.GetInType only checks the parameter name, is wrongly marked as "InType.Path".
Please, consider adding braces "{}" when searching the Uri for parameter placeholders.

Array types mapping

The types contained in a collection aren't mapped the same way as property types. For example, when a string property is processed, it's displayed as simply "string" but when a collection of strings is encountered, it's shown as "System.String", and that is unnecessarily listed as an inline type.

image

Ideally, IMO, this would read "Segments ([string]):" (i.e., JS array notation) or, to be more explicit, "Segments (Array[string]):"

I'm not immediately sure how to improve this, though. I was thinking that DefinitionsBuilder.ProcessProperties should be calling Helpers.MapSwaggerType instead of using the type directly (prop.Items.Ref = t.FullName), but that's going to require passing around the definitions list in several more places. I tinkered with it, but ended up with "Inline Type 1" instead.

Double/decimal value don't appear into the Model Schema

Hi, I don't know how to "reopen" a ticket, so I'll create a new one:

Hi, double or decimal value appear in Model of "Data Type" as a "number", but doesn't appear in "Model Schema".

Check the attach screen capture, see the longitude and latitude:
179012ba-4207-11e6-8e83-2e177d43f5660

BodyStyle != WebMessageBodyStyle.Bare issue

Hi Abel,

We wanted to document our WCF RESTFul service with your Swagger WCF, but we encounter the following issue.
When in WebInvoke attribute of operation in our WCF service we set BodyStyle to WebMessageBodyStyle.WrappedRequest (or anything different from Bare), we get Bad Request Error.
We would like to know whether it is possible to make work the SwaggerWCF with this type of body? And how it can be achieved?

Regards,
Aleksander

minor issues

Hi, I just tried to use your service component.

Three issues I discovered so far:

  1. Swagger file has no content if WebGet/WebInvoke attributes are placed on the implementing methods, rather than interface. I know it is not recommended, but it is permissible.
  2. Code fails with "null reference exception" when WebInvoke attrib has no Method argument - POST is the default value.
  3. Even swagger content is internally properly built no file gets returned. GetSwaggerFile() method completes but browser gets stacked displaying "fetching resource list: http://localhost:63780/api-docs/swagger.json". In my case the content is just ~ 9k.

Best regards,

Tomasz

Object reference not set to an instance of an object.

Following setup and navigating to http://localhost:58170/api-docs receive below error. Any ideas how to investigate further? i.e server logs location?

The server encountered an error processing the request. The exception message is 'Object reference not set to an instance of an object.'. See server logs for more details. The exception stack trace is:
at SwaggerWcf.Support.Serializer.Process(Service service) at SwaggerWcf.SwaggerWcfEndpoint.GetSwaggerFile() at SyncInvokeGetSwaggerFile(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.