swagger-converter

WebJar for swagger-converter

License

License

MIT
Categories

Categories

Swagger Program Interface REST Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

swagger-converter
Last Version

Last Version

0.1.7
Release Date

Release Date

Type

Type

jar
Description

Description

swagger-converter
WebJar for swagger-converter
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/apigee-127/swagger-converter

Download swagger-converter

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/swagger-converter/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>swagger-converter</artifactId>
    <version>0.1.7</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/swagger-converter/
implementation 'org.webjars.npm:swagger-converter:0.1.7'
// https://jarcasting.com/artifacts/org.webjars.npm/swagger-converter/
implementation ("org.webjars.npm:swagger-converter:0.1.7")
'org.webjars.npm:swagger-converter:jar:0.1.7'
<dependency org="org.webjars.npm" name="swagger-converter" rev="0.1.7">
  <artifact name="swagger-converter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='swagger-converter', version='0.1.7')
)
libraryDependencies += "org.webjars.npm" % "swagger-converter" % "0.1.7"
[org.webjars.npm/swagger-converter "0.1.7"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : lodash.clonedeep jar [2.4.1,3)

Project Modules

There are no modules declared in this project.

Swagger Converter

NPM version Build status Coverage Status Dependency status devDependency status

Join the chat at https://gitter.im/apigee-127/swagger-converter

Converts Swagger documents from version 1.x to version 2.0

Installation

Use npm

npm install swagger-converter --save

Usage

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 function

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 values
  • options(optional) - See options for the full list of options
var 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

listApiDeclarations function accept following arguments:

  • sourceUrl(required) - source URL for root Swagger 1.x document
  • resourceListing(required) - root Swagger 1.x document
var 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"
}
*/

Options

  • collectionFormat[string] - assigned to every array parameter.
  • buildTagsFromPaths[bool] - ignore resourcePath and buid tags from resource path. Default: false.

Development

Install dependencies with npm install command and use npm test to run the test. Tests will fail if you break coding style.

Building for browser

Just run this command to make a new browser.js

npm run build

License

MIT. See LICENSE

org.webjars.npm

Apigee-127

Tools for building APIs using Node and OpenAPI

Versions

Version
0.1.7