Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
swagger-converter
Advanced tools
Converts Swagger documents from version
1.x
to version2.0
Use npm
npm install swagger-converter --save
It's recommended to use command line tools like swagger-tools
or swagger-spec-converter
for converting your spec. This module will not handle validation and if your spec is not valid can produce invalid spec.
convert
accept accept following arguments:
resourceListing
(required) is Swagger 1.x entry point file.apiDeclarations
(required) is a map with paths from resourceListing
as keys and resources as valuesoptions
(optional) - See options for the full list of optionsvar swaggerConverter = require('swagger-converter');
var resourceListing = require('/path/to/petstore/index.json');
var apiDeclarations = {
'/pet': require('/path/to/petstore/pet.json'),
'/user': require('/path/to/petstore/user.json'),
'/store': require('/path/to/petstore/store.json'),
};
var swagger2Document = swaggerConverter.convert(
resourceListing,
apiDeclarations,
);
console.log(JSON.stringify(swagger2Document, null, 2));
listApiDeclarations
function accept following arguments:
sourceUrl
(required) - source URL for root Swagger 1.x documentresourceListing
(required) - root Swagger 1.x documentvar swaggerConverter = require('swagger-converter');
var resourceListing = require('/path/to/petstore/index.json');
var apiDeclarations = swaggerConverter.listApiDeclarations(
'http://test.com/api-docs',
resourceListing,
);
console.log(JSON.stringify(apiDeclarations, null, 2));
/*
{
"/pet": "http://test.com/api-docs/pet",
"/user": "http://test.com/api-docs/user",
"/store": "http://test.com/api-docs/store"
}
*/
collectionFormat
[string] - assigned to every array parameter.buildTagsFromPaths
[bool] - ignore resourcePath
and buid tags from resource path
. Default: false.Install dependencies with npm install
command and use npm test
to run the test. Tests will fail if you break coding style.
Just run this command to make a new browser.js
npm run build
MIT. See LICENSE
FAQs
Converts Swagger documents from version 1.x to version 2.0
We found that swagger-converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.