GithubHelp home page GithubHelp logo

Comments (10)

tmveni avatar tmveni commented on July 4, 2024 1

Hi, for SwaggerWcf there is any way to write dynamically instead of hardcoding the basepath, wanted to get from web.config/app.config file.

from swaggerwcf.

abelsilva avatar abelsilva commented on July 4, 2024

If you follow the installation guide, you will be adding SwaggerWcf to your own API.

SwaggerWcf will be available on the same location as your API, the only change will be the path

If you use

 RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));

SwaggerWcf will be available at http://your.api.host/api-docs

Or maybe I didn't understand your question :)

from swaggerwcf.

davidverriere avatar davidverriere commented on July 4, 2024

from swaggerwcf.

abelsilva avatar abelsilva commented on July 4, 2024

but whatever URL you end up configuring for your api endpoint dynamically should be the same for swaggerwcf, when you open http://[...]/api-docs, the swagger JSON will come from same place: http://[...]/api-docs/swagger.json

from swaggerwcf.

abelsilva avatar abelsilva commented on July 4, 2024

if you check this gist
https://gist.github.com/abelsilva/ac4ae0aeaf90c93adf0dcbaa6dca8cfa

After having this application running, I can access the api-docs using IPs or hostname and it will work
The swagger JSON url will also update based on the address I'm using

from swaggerwcf.

davidverriere avatar davidverriere commented on July 4, 2024

Thanks for your help
I can't use config file to define my enpoint, everithing is configured by code.
My api endpoint is https://localhost/EurekaDave/api/admin/supervisor/
My swagger documentation endpoint is https://localhost/EurekaDave/admin/api/docs/
Everthing works fine except samples
image
Endpoint url in sample is https://localhost/supervisor, but my endpoint api url https://localhost/EurekaDave/api/admin/supervisor/

I would like set api base adresse for sample documentation when api documentation host is starting

Here how i am instantiating swagger endpoint
WebServiceHost apiHost = new WebServiceHost(typeof(SwaggerWcfEndpoint), new Uri[] { new Uri($"https://{this.machineName}/{ApiHostStarter.DispatchLicenseCode}/Admin/Api/Doc") }); apiHost.Open();

from swaggerwcf.

SeeSharp7 avatar SeeSharp7 commented on July 4, 2024

Yes, you are able to change the path of your swagger api (but wcf base path must be the same). I'm also working in selfhosted services an this is the way, I create dynamic servicehosts. I hope, I can help you out.

    private void CreateSwaggerServiceHost<TBusiness>()
      {
          var interfaces = typeof(SwaggerWcfEndpoint).GetInterfaces();

          if (interfaces.Length != 1)
              throw new InvalidOperationException("SwaggerWcfEndpoint implements more than one Interface! Only one contract is expected");

          var swaggerHost = new WebServiceHost(typeof(SwaggerWcfEndpoint), BuildSwaggerUri<TBusiness>());
          swaggerHost.AddServiceEndpoint(interfaces[0], new WebHttpBinding(), string.Empty);

          _swaggerHosts.Add(swaggerHost);
      }
 private Uri BuildSwaggerUri<TBusiness>()
        {
            var serviceUri = new Uri(_baseUri, $"{_serviceName}/v{GetServiceVersion<TBusiness>()}/{SwaggerUriSuffix}");
            return serviceUri;
        }

from swaggerwcf.

davidverriere avatar davidverriere commented on July 4, 2024

Thanks for your help.
Swagger still works with endpoint adding by code but sample target the wrong url
image
Endpoint url in sample is https://localhost/supervisor, but my endpoint api url https://localhost/**EurekaDave/api/admin**/supervisor/

I saw some post with javascript patch to workaround wrong uri sample.

from swaggerwcf.

SeeSharp7 avatar SeeSharp7 commented on July 4, 2024

Ah, okay! Maybe your problem is located here:

  • Check your Base Path defined in your swagger configuration section (app.config/web.config)
  • Check the SwaggerWcfAttribute with Base Path, i. e. [SwaggerWcf("/myservice/v1")]

Are there differences between your endpoint uri?

from swaggerwcf.

abelsilva avatar abelsilva commented on July 4, 2024

let me know if you still need help to reopen the issue

from swaggerwcf.

Related Issues (20)

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.