Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to any version higher than release 0.2.9 #177

Open
DanielSCBO opened this issue Sep 10, 2018 · 6 comments
Open

Upgrading to any version higher than release 0.2.9 #177

DanielSCBO opened this issue Sep 10, 2018 · 6 comments

Comments

@DanielSCBO
Copy link

DanielSCBO commented Sep 10, 2018

Hello ppl after update to new version my swagger dont work:

`

em SwaggerWcf.Support.TypeExtensions.GetServiceInfo(TypeInfo typeInfo) em C:\Users\Daniel\Downloads\swaggerwcf-master\swaggerwcf-master\src\SwaggerWcf\Support\TypeExtensions.cs:line 30 em SwaggerWcf.Support.ServiceBuilder.BuildPaths(Service service, IList1 hiddenTags, List1 visibleTags, IList1 definitionsTypesList) em C:\Users\Daniel\Downloads\swaggerwcf-master\swaggerwcf-master\src\SwaggerWcf\Support\ServiceBuilder.cs:line 121 em SwaggerWcf.Support.ServiceBuilder.BuildServiceCommon(String path, Action4 buildPaths) em C:\Users\Daniel\Downloads\swaggerwcf-master\swaggerwcf-master\src\SwaggerWcf\Support\ServiceBuilder.cs:line 40 em SwaggerWcf.Support.ServiceBuilder.Build(String path) em C:\Users\Daniel\Downloads\swaggerwcf-master\swaggerwcf-master\src\SwaggerWcf\Support\ServiceBuilder.cs:line 18 em SwaggerWcf.SwaggerWcfEndpoint.Init(Func2 buildService) em C:\Users\Daniel\Downloads\swaggerwcf-master\swaggerwcf-master\src\SwaggerWcf\SwaggerWcfEndpoint.cs:line 61 em SwaggerWcf.SwaggerWcfEndpoint..ctor() em C:\Users\Daniel\Downloads\swaggerwcf-master\swaggerwcf-master\src\SwaggerWcf\SwaggerWcfEndpoint.cs:line 23 em CreateSwaggerWcf.SwaggerWcfEndpoint() em System.ServiceModel.Dispatcher.InstanceProvider.GetInstance(InstanceContext instanceContext, Message message) em System.ServiceModel.Dispatcher.InstanceBehavior.GetInstance(InstanceContext instanceContext, Message request) em System.ServiceModel.InstanceContext.GetServiceInstance(Message message) em System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) em System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) em System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)``

I Fill the info Info attribute when Configure EndPoint:


            var info = new SwaggerWcf.Models.Info
            {
                Version = "1.0.0",
                Title = "WebService",
                Description = "WebService Descr",
                TermsOfService = "s asas",
                Contact = new SwaggerWcf.Models.InfoContact()
                {
                    Name = "Daniel",
                    Email ="[email protected]",
                    Url = "http://google.pt"
                },
                License = new SwaggerWcf.Models.InfoLicense()
                {
                    Name ="-",
                    Url = "http://google.pt"

                }
            };
`     SwaggerWcf.SwaggerWcfEndpoint.Configure(info, null);`

I open project and do a little debug and found on:

SwaggerWcf\Support\TypeExtensions.cs
Function GetServiceInfo line 30

the following line

          var infoAttr = typeInfo.GetCustomAttribute<SwaggerWcfServiceInfoAttribute>() ??
                throw new ArgumentException($"{typeInfo.FullName} does not have {nameof(SwaggerWcfServiceInfoAttribute)}");

Change to

  var infoAttr = typeInfo.GetCustomAttribute<SwaggerWcfServiceInfoAttribute>();
            if (infoAttr == null && SwaggerWcfEndpoint.Info != null)
                return SwaggerWcfEndpoint.Info;
            else if (infoAttr == null && SwaggerWcfEndpoint.Info == null)
                throw new ArgumentException($"{typeInfo.FullName} does not have {nameof(SwaggerWcfServiceInfoAttribute)}");

And not all Works

I do not have a way to set the attribute on the interface because I have 10 different interfaces in webservice
Its possible to pull the fix to main repo?

cumps

@justin0522
Copy link
Contributor

Add the following to your config file and change the values accordingly
<swaggerwcf> <settings> <setting name="InfoDescription" value="Sample Service to test SwaggerWCF" /> <setting name="InfoVersion" value="0.0.1" /> <setting name="InfoTermsOfService" value="Terms of Service" /> <setting name="InfoTitle" value="SampleService" /> <setting name="InfoContactName" value="Abel Silva" /> <setting name="InfoContactUrl" value="http://github.com/abelsilva" /> <setting name="InfoContactEmail" value="[email protected]" /> <setting name="InfoLicenseUrl" value="https://github.com/abelsilva/SwaggerWCF/blob/master/LICENSE" /> <setting name="InfoLicenseName" value="Apache License" /> </settings> </swaggerwcf>

@DanielSCBO
Copy link
Author

Hello i dont use config file i use WebServiceHost

Example of creation

var swaggerHost = new WebServiceHost(typeof(SwaggerWcf.SwaggerWcfEndpoint), new Uri(URL));


          var info = new SwaggerWcf.Models.Info
          {
              Version = "1.1.0",
              Title = "WebService",
              Description = "WebService",
              TermsOfService = "",
              Contact = new SwaggerWcf.Models.InfoContact()
              {
                  Name = "teste,
                  Email ="[email protected]",
                  Url = "http://google.pt"
              },
              License = new SwaggerWcf.Models.InfoLicense()
              {
                  Name = "Copyright",
                  Url = "http://google.pt"

              }
          };

          **SwaggerWcf.SwaggerWcfEndpoint.Configure(info, null);**

          swaggerHost.Open();

@DanielSCBO
Copy link
Author

I made a pull request #178, if you want to accept ...

@justin0522
Copy link
Contributor

justin0522 commented Sep 11, 2018

it is not wcf config, it is swaggerwcf config.
https://github.com/abelsilva/swaggerwcf/blob/master/README.md
Step 4: Configure WCF services general information

for the service info property, there are three sources (appear in order):

  1. the config file
  2. SwaggerWcfServiceInfoAttribute
  3. SwaggerWcfEndpoint.Configure(info, null)

1 is higher than 2, 3 is highest priority

@DanielSCBO
Copy link
Author

I use method 3 and dont work,,, the static var dont pass to GetServiceInfo function

@justin0522
Copy link
Contributor

yes, you are right.
if you don't use method 1, either method 2, there will be a exception in method 2.
if you use method 1, method 2 will not run, and method 3 will override method 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants