Using a local api doc schema? Use the parameter --api-doc-file-path instead of --api-doc-url.
Programatic Usage
var fs = require('fs');var fetchOpenapi = require('fetch-openapi');// See http://petstore.swagger.io/v2/swagger.json for an example API doc.var apiDoc = require('./petstore-api-doc.json');var options = { preset: 'node'};// generator is a string of javascript.var generator = fetchOpenApi(apiDoc, options);fs.writeFileSync('./petStore.js', generator, 'utf8');// now we can use the client.var petStore = require('./petStore');petStore.addPet({/* data */})// => handle the promise
API
fetchOpenapi(apiDoc, options)
Outputs a createApi function represented as a string of javascript that
you can either eval or write to a file.
Valid values are node and es6. With node, module.exports is used. With es6, export is used.
createApi(options)
Creates a service you use to call your API. Each method of the service is named after the operationId of your API's path operations.
options
options.cors
Enables cors support for fetch calls.
options.securityHandlers
An object of security scheme name / handler function. The handler function receives 3 arguments: headers, params, and schemePart. The handler function returns true if the security scheme is supported, false otherwise.
LICENSE
The MIT License (MIT)Copyright (c) 2016 Kogo Software LLCPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.