mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Merge branch 'fix/referencedComponents' into fix/refprop20
This commit is contained in:
@@ -23,6 +23,21 @@ const COMPONENTS_KEYS_30 = [
|
||||
],
|
||||
PROPERTY_DEFINITION = [
|
||||
'properties'
|
||||
],
|
||||
RESPONSE_DEFINITION = [
|
||||
'responses'
|
||||
],
|
||||
REQUEST_BODY_CONTAINER = [
|
||||
'requestBody'
|
||||
],
|
||||
LINKS_CONTAINER = [
|
||||
'links'
|
||||
],
|
||||
HEADER_DEFINITION = [
|
||||
'headers'
|
||||
],
|
||||
CALLBACK_DEFINITION = [
|
||||
'callbacks'
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
@@ -55,6 +70,12 @@ module.exports = {
|
||||
if (EXAMPLE_CONTAINERS.includes(item)) {
|
||||
item = 'examples';
|
||||
}
|
||||
if (REQUEST_BODY_CONTAINER.includes(item)) {
|
||||
item = 'requestBodies';
|
||||
}
|
||||
if (LINKS_CONTAINER.includes(item)) {
|
||||
item = 'links';
|
||||
}
|
||||
if (PROPERTY_DEFINITION.includes(trace[index + 2])) {
|
||||
trace[index + 1] = 'schemas';
|
||||
}
|
||||
@@ -63,6 +84,15 @@ module.exports = {
|
||||
matchFound = true;
|
||||
break;
|
||||
}
|
||||
if (RESPONSE_DEFINITION.includes(trace[index + 2])) {
|
||||
trace[index + 1] = 'responses';
|
||||
}
|
||||
if (HEADER_DEFINITION.includes(trace[index + 2])) {
|
||||
trace[index + 1] = 'headers';
|
||||
}
|
||||
if (CALLBACK_DEFINITION.includes(trace[index + 2])) {
|
||||
trace[index + 1] = 'callbacks';
|
||||
}
|
||||
}
|
||||
return matchFound ?
|
||||
traceToKey.reverse() :
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
{
|
||||
"openapi": "3.0",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"host": "petstore.swagger.io",
|
||||
"basePath": "/api",
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n",
|
||||
"operationId": "findPets",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/~1spec~1parameters.yaml%23~1tagsParam"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/parameters/~1spec~1parameters.yaml%23~1limitsParam"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/~1spec~1Pet.yaml"
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1common~1Error.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Creates a new pet in the store. Duplicates are allowed",
|
||||
"operationId": "addPet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "pet",
|
||||
"in": "body",
|
||||
"description": "Pet to add to the store",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1NewPet.yaml"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1Pet.yaml"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1common~1Error.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pets/{id}": {
|
||||
"get": {
|
||||
"description": "Returns a user based on a single ID, if the user does not have access to the pet",
|
||||
"operationId": "find pet by id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "ID of pet to fetch",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1Pet.yaml"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1common~1Error.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "deletes a single pet based on the ID supplied",
|
||||
"operationId": "deletePet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "ID of pet to delete",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "pet deleted"
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/~1spec~1common~1Error.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"parameters": {
|
||||
"/spec/parameters.yaml#/tagsParam": {
|
||||
"name": "tags",
|
||||
"in": "query",
|
||||
"description": "tags to filter by",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"collectionFormat": "csv",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"/spec/parameters.yaml#/limitsParam": {
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
"description": "maximum number of results to return",
|
||||
"required": false,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"/spec/Pet.yaml": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/spec/common/Error.yaml": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"code",
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/spec/NewPet.yaml": {
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/~1spec~1Pet.yaml"
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
test/data/toBundleExamples/referenced_callback/callback.yaml
Normal file
22
test/data/toBundleExamples/referenced_callback/callback.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
'{$request.query.callbackUrl}/data':
|
||||
post:
|
||||
requestBody:
|
||||
description: subscription payload
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
userData:
|
||||
type: string
|
||||
responses:
|
||||
'202':
|
||||
description: |
|
||||
Your server implementation should return this HTTP status code
|
||||
if the data was received successfully
|
||||
'204':
|
||||
description: |
|
||||
Your server should return this HTTP status code if no longer interested
|
||||
in further updates
|
||||
122
test/data/toBundleExamples/referenced_callback/expected.json
Normal file
122
test/data/toBundleExamples/referenced_callback/expected.json
Normal file
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Authorization"
|
||||
],
|
||||
"description": "Returns all pets alesuada ac...",
|
||||
"operationId": "findPets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"callbacks": {
|
||||
"onData": {
|
||||
"$ref": "#/components/callbacks/_callback.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Error": {
|
||||
"required": [
|
||||
"code",
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"callbacks": {
|
||||
"_callback.yaml": {
|
||||
"{$request.query.callbackUrl}/data": {
|
||||
"post": {
|
||||
"requestBody": {
|
||||
"description": "subscription payload",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"userData": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"202": {
|
||||
"description": "Your server implementation should return this HTTP status code\nif the data was received successfully\n"
|
||||
},
|
||||
"204": {
|
||||
"description": "Your server should return this HTTP status code if no longer interested\nin further updates\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
test/data/toBundleExamples/referenced_callback/root.yaml
Normal file
59
test/data/toBundleExamples/referenced_callback/root.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
tags:
|
||||
- Authorization
|
||||
description: Returns all pets alesuada ac...
|
||||
operationId: findPets
|
||||
responses:
|
||||
"200":
|
||||
description: pet response
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
default:
|
||||
description: unexpected error
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
callbacks:
|
||||
onData:
|
||||
$ref: "./callback.yaml"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
Error:
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
73
test/data/toBundleExamples/referenced_header/expected.json
Normal file
73
test/data/toBundleExamples/referenced_header/expected.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"description": "Returns all pets alesuada ac...",
|
||||
"operationId": "findPets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "An paged array of pets",
|
||||
"headers": {
|
||||
"x-next": {
|
||||
"$ref": "#/components/headers/_header.yaml"
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pets"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"headers": {
|
||||
"_header.yaml": {
|
||||
"description": "A link to the next page of responses",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
test/data/toBundleExamples/referenced_header/header.yaml
Normal file
3
test/data/toBundleExamples/referenced_header/header.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
description: A link to the next page of responses
|
||||
schema:
|
||||
type: string
|
||||
43
test/data/toBundleExamples/referenced_header/root.yaml
Normal file
43
test/data/toBundleExamples/referenced_header/root.yaml
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
description: Returns all pets alesuada ac...
|
||||
operationId: findPets
|
||||
responses:
|
||||
200:
|
||||
description: An paged array of pets
|
||||
headers:
|
||||
x-next:
|
||||
$ref: "./header.yaml"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
71
test/data/toBundleExamples/referenced_link/expected.json
Normal file
71
test/data/toBundleExamples/referenced_link/expected.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"description": "Returns all pets alesuada ac...",
|
||||
"operationId": "findPets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
"$ref": "#/components/links/_link.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
"_link.yaml": {
|
||||
"operationId": "getRepository",
|
||||
"parameters": {
|
||||
"username": "$response.body#/owner/username",
|
||||
"slug": "$response.body#/slug"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4
test/data/toBundleExamples/referenced_link/link.yaml
Normal file
4
test/data/toBundleExamples/referenced_link/link.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
operationId: getRepository
|
||||
parameters:
|
||||
username: $response.body#/owner/username
|
||||
slug: $response.body#/slug
|
||||
42
test/data/toBundleExamples/referenced_link/root.yaml
Normal file
42
test/data/toBundleExamples/referenced_link/root.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
description: Returns all pets alesuada ac...
|
||||
operationId: findPets
|
||||
responses:
|
||||
200:
|
||||
description: pet response
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
links:
|
||||
$ref: "./link.yaml"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"description": "Returns all pets alesuada ac...",
|
||||
"operationId": "findPets",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/_hello.yaml"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"_hello.yaml": {
|
||||
"name": "tags",
|
||||
"in": "query",
|
||||
"description": "tags to filter by",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"collectionFormat": "csv",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
name: tags
|
||||
in: query
|
||||
description: tags to filter by
|
||||
required: false
|
||||
type: array
|
||||
collectionFormat: csv
|
||||
items:
|
||||
type: string
|
||||
42
test/data/toBundleExamples/referenced_parameter/root.yaml
Normal file
42
test/data/toBundleExamples/referenced_parameter/root.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
description: Returns all pets alesuada ac...
|
||||
operationId: findPets
|
||||
parameters:
|
||||
- $ref: "./hello.yaml"
|
||||
responses:
|
||||
200:
|
||||
description: pet response
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"post": {
|
||||
"operationId": "savePets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/_hello.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodies": {
|
||||
"_hello.yaml": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"address": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
address:
|
||||
type: string
|
||||
41
test/data/toBundleExamples/referenced_request_body/root.yaml
Normal file
41
test/data/toBundleExamples/referenced_request_body/root.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/pets:
|
||||
post:
|
||||
operationId: savePets
|
||||
responses:
|
||||
200:
|
||||
description: pet response
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
requestBody:
|
||||
$ref: "./hello.yaml"
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
52
test/data/toBundleExamples/referenced_response/expected.json
Normal file
52
test/data/toBundleExamples/referenced_response/expected.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/hello": {
|
||||
"get": {
|
||||
"description": "Returns all pets alesuada ac...",
|
||||
"operationId": "findPets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/_hello.yaml"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"responses": {
|
||||
"_hello.yaml": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"address": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
address:
|
||||
type: string
|
||||
22
test/data/toBundleExamples/referenced_response/root.yaml
Normal file
22
test/data/toBundleExamples/referenced_response/root.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/hello:
|
||||
get:
|
||||
description: Returns all pets alesuada ac...
|
||||
operationId: findPets
|
||||
responses:
|
||||
200:
|
||||
$ref: "./hello.yaml"
|
||||
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"openapi": "3.0.2",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Authorization"
|
||||
],
|
||||
"description": "Returns all pets alesuada ac...",
|
||||
"operationId": "findPets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Error": {
|
||||
"required": [
|
||||
"code",
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
"petstore_auth": {
|
||||
"type": "oauth2",
|
||||
"flows": {
|
||||
"implicit": {
|
||||
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
|
||||
"scopes": {
|
||||
"write:pets": "modify pets in your account",
|
||||
"read:pets": "read your pets"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
openapi: "3.0.2"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
name: Swagger API Team
|
||||
email: apiteam@swagger.io
|
||||
url: http://swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
tags:
|
||||
- Authorization
|
||||
description: Returns all pets alesuada ac...
|
||||
operationId: findPets
|
||||
responses:
|
||||
"200":
|
||||
description: pet response
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
default:
|
||||
description: unexpected error
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
security:
|
||||
- petstore_auth:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
Error:
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
$ref: "./sschemes.yaml"
|
||||
@@ -0,0 +1,7 @@
|
||||
type: oauth2
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
|
||||
scopes:
|
||||
'write:pets': modify pets in your account
|
||||
'read:pets': read your pets
|
||||
@@ -45,7 +45,14 @@ let expect = require('chai').expect,
|
||||
refExample20 = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/referenced_example'),
|
||||
properties = path.join(__dirname, BUNDLES_FOLDER + '/properties'),
|
||||
sameSourceDifferentPlace = path.join(__dirname, BUNDLES_FOLDER + '/same_source_different_place'),
|
||||
nestedProperties = path.join(__dirname, BUNDLES_FOLDER + '/nestedProperties');
|
||||
nestedProperties = path.join(__dirname, BUNDLES_FOLDER + '/nestedProperties'),
|
||||
referencedResponse = path.join(__dirname, BUNDLES_FOLDER + '/referenced_response'),
|
||||
referencedParameter = path.join(__dirname, BUNDLES_FOLDER + '/referenced_parameter'),
|
||||
referencedRequestBody = path.join(__dirname, BUNDLES_FOLDER + '/referenced_request_body'),
|
||||
referencedHeader = path.join(__dirname, BUNDLES_FOLDER + '/referenced_header'),
|
||||
referencedLink = path.join(__dirname, BUNDLES_FOLDER + '/referenced_link'),
|
||||
referencedCallback = path.join(__dirname, BUNDLES_FOLDER + '/referenced_callback'),
|
||||
referencedSecuritySchemes = path.join(__dirname, BUNDLES_FOLDER + '/referenced_security_schemes');
|
||||
|
||||
describe('bundle files method - 3.0', function () {
|
||||
it('Should return bundled file as json - schema_from_response', async function () {
|
||||
@@ -1533,6 +1540,231 @@ describe('bundle files method - 3.0', function () {
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced response', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedResponse + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedResponse + '/hello.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedResponse + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/hello.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced Parameter', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedParameter + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedParameter + '/hello.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedParameter + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/hello.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced Request Body', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedRequestBody + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedRequestBody + '/hello.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedRequestBody + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/hello.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced Header', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedHeader + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedHeader + '/header.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedHeader + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/header.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced Link', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedLink + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedLink + '/link.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedLink + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/link.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced Callback', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedCallback + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedCallback + '/callback.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedCallback + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/callback.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - referenced Security Schemes', async function () {
|
||||
let contentRoot = fs.readFileSync(referencedSecuritySchemes + '/root.yaml', 'utf8'),
|
||||
contentRef = fs.readFileSync(referencedSecuritySchemes + '/sschemes.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(referencedSecuritySchemes + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRoot
|
||||
},
|
||||
{
|
||||
path: '/sschemes.yaml',
|
||||
content: contentRef
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
const res = await Converter.bundle(input);
|
||||
|
||||
expect(res).to.not.be.empty;
|
||||
expect(res.result).to.be.true;
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
|
||||
@@ -22,7 +22,6 @@ describe('getKeyInComponents function', function () {
|
||||
|
||||
it('should return ["schemas", "_folder_pet.yaml"] when the filename scaped slash', function () {
|
||||
const result = getKeyInComponents(['path', 'schemas'], '~1folder~1pet.yaml');
|
||||
|
||||
expect(result).to.be.an('array').with.length(2);
|
||||
expect(result[0]).to.equal('schemas');
|
||||
expect(result[1]).to.equal('_folder_pet.yaml');
|
||||
@@ -30,7 +29,6 @@ describe('getKeyInComponents function', function () {
|
||||
|
||||
it('should return ["schemas", "_folder_pet.yaml"] when the filename contains any slash', function () {
|
||||
const result = getKeyInComponents(['path', 'schemas'], '/folder/pet.yaml');
|
||||
|
||||
expect(result).to.be.an('array').with.length(2);
|
||||
expect(result[0]).to.equal('schemas');
|
||||
expect(result[1]).to.equal('_folder_pet.yaml');
|
||||
@@ -39,7 +37,6 @@ describe('getKeyInComponents function', function () {
|
||||
it('should return ["schemas", "_folder_pet.yaml-_Name"] when the filename contains any sacped slash' +
|
||||
'and a local part using a scaped sharp', function () {
|
||||
const result = getKeyInComponents(['path', 'schemas'], '~1folder~1pet.yaml%23~1Name');
|
||||
|
||||
expect(result).to.be.an('array').with.length(2);
|
||||
expect(result[0]).to.equal('schemas');
|
||||
expect(result[1]).to.equal('_folder_pet.yaml-_Name');
|
||||
@@ -48,7 +45,6 @@ describe('getKeyInComponents function', function () {
|
||||
it('should return ["schemas", "_folder_pet.yaml-_Name"] when the filename contains any slash' +
|
||||
'and a local part using a sharp', function () {
|
||||
const result = getKeyInComponents(['path', 'schemas'], '/folder/pet.yaml#/Name');
|
||||
|
||||
expect(result).to.be.an('array').with.length(2);
|
||||
expect(result[0]).to.equal('schemas');
|
||||
expect(result[1]).to.equal('_folder_pet.yaml-_Name');
|
||||
@@ -57,7 +53,6 @@ describe('getKeyInComponents function', function () {
|
||||
it('should return ["schemas", "_foldertest_pet.yaml-_Name"] when the filename contains any slash' +
|
||||
'and a local part using a sharp and another not valid character', function () {
|
||||
const result = getKeyInComponents(['path', 'schemas'], '/folder@test/pet@.yaml#/Name');
|
||||
|
||||
expect(result).to.be.an('array').with.length(2);
|
||||
expect(result[0]).to.equal('schemas');
|
||||
expect(result[1]).to.equal('_foldertest_pet.yaml-_Name');
|
||||
@@ -117,7 +112,6 @@ describe('concatJsonPointer function ', function () {
|
||||
['schemas', 'some_Pet.yaml'],
|
||||
'/components'
|
||||
);
|
||||
|
||||
expect(res).to.equal('#/components/schemas/some_Pet.yaml');
|
||||
});
|
||||
|
||||
@@ -135,7 +129,6 @@ describe('concatJsonPointer function ', function () {
|
||||
['schemas', '_Pets.yaml'],
|
||||
'/components'
|
||||
);
|
||||
|
||||
expect(res).to.equal('#/components/schemas/_Pets.yaml');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user