Comments (10)
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.
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.
from swaggerwcf.
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.
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.
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
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.
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.
Thanks for your help.
Swagger still works with endpoint adding by code but sample target the wrong url
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.
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.
let me know if you still need help to reopen the issue
from swaggerwcf.
Related Issues (20)
- ServiceContract Attribute
- swagger.json file loses details over time HOT 1
- swaggerwcf CPU 100%
- Models NameSpaces.Class but I want just CLass HOT 3
- Request Error while access external models as parameters
- Swaggerwcf doesn't support ServiceContracts with the same methodsname.
- SwaggerWCF issue with routes and yaml HOT 1
- Adding Basic Authentication
- Adding project as a reference - failed to parse JSON/YAML response
- Unclear instuction WebServiceHost / Self Host HOT 3
- returning multiple types
- Generate multiple-files based on different WCF classes or tags HOT 2
- Request URL HOT 1
- URL issue
- In IIS , response body as "no centent" for swaggerWCF HOT 1
- NullReferenceException on GetEnumDescription
- Enum return value not included in definitions
- How to get Swagger json inside my API ?
- Setting an example value when there's an object on GET method
- ProcessProperty() of TypePropertiesProcessor.cs not handling IList type, Solution here.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swaggerwcf.