From 8c08afa0c08c1bb74689a3f00058d6b884ef4283 Mon Sep 17 00:00:00 2001 From: Tomoya Iwata Date: Sun, 6 Mar 2022 00:07:57 +0900 Subject: [PATCH] test: add test case for merge definition that include {} --- test/in.json | 5 ++- test/in.yaml | 2 + test/out.json | 105 +++++++++++++++++++++++++++++++++++++++++++++++++- test/out.yaml | 73 +++++++++++++++++++++++++++++++++++ 4 files changed, 183 insertions(+), 2 deletions(-) diff --git a/test/in.json b/test/in.json index 5fc0937..43de179 100644 --- a/test/in.json +++ b/test/in.json @@ -44,7 +44,10 @@ "$ref#pets": "./paths/pets", "$ref#pets-id": "https://raw.githubusercontent.com/WindomZ/swagger-merger/pets-id", "$ref#no-ext": "./no_ext_json", - "$ref#wrong-ext": "./wrong_ext.xml" + "$ref#wrong-ext": "./wrong_ext.xml", + "/v2/pets/{id}": { + "$ref": "./simple_json#/paths/~1pets~1{id}" + } }, "definitions": { "$ref#pets": "https://raw.githubusercontent.com/WindomZ/swagger-merger/pets.yaml", diff --git a/test/in.yaml b/test/in.yaml index 255dd9a..42ea216 100644 --- a/test/in.yaml +++ b/test/in.yaml @@ -32,6 +32,8 @@ paths: $ref#pets-id: "https://raw.githubusercontent.com/WindomZ/swagger-merger/pets-id" $ref#no-ext: "./no_ext_yaml" $ref#wrong-ext: "./wrong_ext.xml" + /v2/pets/{id}: + $ref: ./simple_yaml#/paths/~1pets~1{id} definitions: $ref#pets: "https://raw.githubusercontent.com/WindomZ/swagger-merger/pets.yaml" $ref#error: "https://raw.githubusercontent.com/WindomZ/swagger-merger/master/example/petstore_simple/definitions/error.yaml" diff --git a/test/out.json b/test/out.json index e90411a..169a17a 100644 --- a/test/out.json +++ b/test/out.json @@ -52,7 +52,110 @@ "/pets/{id}": { "good": "bye" }, - "$ref#wrong-ext": "./wrong_ext.xml" + "$ref#wrong-ext": "./wrong_ext.xml", + "/v2/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/xml", + "text/html" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "default": { + "description": "unexpected error", + "schema": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "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": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } }, "definitions": { "$ref#pets": "https://raw.githubusercontent.com/WindomZ/swagger-merger/pets.yaml", diff --git a/test/out.yaml b/test/out.yaml index 5e67350..1dc78db 100644 --- a/test/out.yaml +++ b/test/out.yaml @@ -41,6 +41,79 @@ paths: /pets/{id}: good: bye $ref#wrong-ext: ./wrong_ext.xml + /v2/pets/{id}: + get: + description: >- + Returns a user based on a single ID, if the user does not have access to + the pet + operationId: findPetById + produces: + - application/json + - application/xml + - text/xml + - text/html + parameters: + - name: id + in: path + description: ID of pet to fetch + required: true + type: integer + format: int64 + responses: + '200': + description: pet response + schema: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + default: + description: unexpected error + schema: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string + 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: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string definitions: $ref#pets: https://raw.githubusercontent.com/WindomZ/swagger-merger/pets.yaml errorModel: