use this client with a swagger spec on local machine?
See original GitHub issueI want to use the client as following in my code:
var SwaggerClient = require('swagger-client');
var client = new SwaggerClient({
url: '../swagger/sampleSwaggerAPI.yaml',
success: function() {
...
}
});
Is that doable or does this work only with hosted swagger specs
only?
@fehguy ^ thoughts please.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Getting Started with OpenAPI Tools | Swagger Open Source
Swagger is the most widely used tooling ecosystem for developing APIs with the OpenAPI Specification(OAS). Learn more about out open source and professional ......
Read more >Installation - Swagger Documentation
Plain old HTML/CSS/JS (Standalone) Open swagger-initializer. js in your text editor and replace "https://petstore.swagger.io/v2/swagger.json" with the URL for ...
Read more >Setting up a dev environment - Swagger Documentation
You can specify a local file in dev-helpers/swagger-initializer.js by changing the url parameter. This local file MUST be located in the dev-helpers directory ......
Read more >How to Use Swagger Inspector
To the right of the method option is the URI input. Choose the base URI and path of the API you'd like to...
Read more >Swagger Codegen Documentation
The Swagger Codegen is an open source code-generator to build server stubs and client SDKs directly from a Swagger defined RESTful API. The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hi @gunjpan, can you load the contents of your
../swagger/sampleSwaggerApi.yaml
as an object? If so, you can easily do this:Then the object can be loaded however you like, and the swagger client will process it. Note! The
url
field is still needed. Why might you ask? Because there may be references to other swagger constructs inside your object, and the client will need that for resolving them.@waytoharish : here is where I’m using
SwaggerClient
: https://github.com/strongloop/loopback-connector-swagger/blob/a656eedd5490869152ed3e62a708bc4de13bf00d/lib/swagger-connector.js#L107-L119and here is the function where I’m parsing a local file: https://github.com/strongloop/loopback-connector-swagger/blob/a656eedd5490869152ed3e62a708bc4de13bf00d/lib/spec-resolver.js#L14
Hope that helps