openapi-utils-defaults
v0.0.7
Published
Defaults api parts into an openapi definition
Downloads
24
Readme
openapi-utils-defaults
Defaults api parts into an openapi definition.
Installation
npm install -g openapi-utils-defaults
Usage
Given the example files displayed below (api.yaml and x-a127.yaml), the following command
openapi-utils-defaults -s x-a127.yaml -t api.yaml > api.json
Will result in the api.json, also displayed below :)
Example api.yaml
swagger: "2.0"
info:
version: 1.0.0
title: openapi example
basePath: /v1
paths:
/pets:
x-a127-services:
- name: add-cors
provider: x-cors
options:
displayName: Add CORS
includeInErrorResponse: true
headers:
Access-Control-Allow-Methods:
type: array
collectionFormat: csv
default: GET
Example x-a127.yaml
x-a127-services:
- name: add-cors
provider: x-cors
options:
displayName: Add CORS
includeInErrorResponse: true
headers:
Access-Control-Allow-Origin:
type: string
default: "*"
Access-Control-Allow-Methods:
type: array
collectionFormat: csv
default: GET, PUT, POST, DELETE
Result api.json
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "openapi example"
},
"basePath": "/v1",
"paths": {
"/pets": null
},
"x-a127-services": [
{
"name": "add-cors",
"provider": "x-cors",
"options": {
"displayName": "Add CORS",
"includeInErrorResponse": true,
"headers": {
"Access-Control-Allow-Origin": {
"type": "string",
"default": "*"
},
"Access-Control-Allow-Methods": {
"type": "array",
"collectionFormat": "csv",
"default": "GET"
}
}
}
}
]
}