question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

use this client with a swagger spec on local machine?

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
fehguycommented, Apr 13, 2016

hi @gunjpan, can you load the contents of your ../swagger/sampleSwaggerApi.yaml as an object? If so, you can easily do this:

// you load the `spec` as an object
var spec = { swagger: '2.0', ....};
new SwaggerClient({
  url: 'STILL_NEEDED!',
  spec: spec,
  ...
}

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found