diff --git a/.vscode/launch.json b/.vscode/launch.json index 550691b..22349f9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,7 @@ "dist/test", "--timeout=2000000" ], - "cwd": "${workspaceRoot}/libraries/deduplication", + "cwd": "${workspaceRoot}/libraries/oai2-to-oai3", "outFiles": [ "${workspaceFolder}/**/*.js" ] diff --git a/libraries/oai2-to-oai3/main.ts b/libraries/oai2-to-oai3/main.ts index 8c33bbd..904ff34 100644 --- a/libraries/oai2-to-oai3/main.ts +++ b/libraries/oai2-to-oai3/main.ts @@ -1042,8 +1042,43 @@ export class Oai2ToOai3 { this.visitHeader(responseTarget.headers[h], responseValue.headers[h], jsonPointer); } } + + // copy extensions + for (const { key, pointer: fieldPointer, value } of responsesFieldMembers()) { + if (key.startsWith('x-') && responseTarget[key] === undefined) { + responseTarget[key] = { value: value, pointer: fieldPointer }; + } + } } + + parameterTypeProperties = [ + 'format', + 'minimum', + 'maximum', + 'exclusiveMinimum', + 'exclusiveMaximum', + 'minLength', + 'maxLength', + 'multipleOf', + 'minItems', + 'maxItems', + 'uniqueItems', + 'minProperties', + 'maxProperties', + 'additionalProperties', + 'pattern', + 'enum', + 'default' + ]; + + arrayProperties = [ + 'items', + 'minItems', + 'maxItems', + 'uniqueItems' + ]; + visitHeader(targetHeader: any, headerValue: any, jsonPointer: string) { if (headerValue.$ref) { // GS01/CRITICAL-TO-DO-NELSON -- should that be /components/headers ???? @@ -1058,28 +1093,13 @@ export class Oai2ToOai3 { targetHeader.description = { value: headerValue.description, pointer: jsonPointer }; } - const schemaKeys = [ - 'maximum', - 'exclusiveMaximum', - 'minimum', - 'exclusiveMinimum', - 'maxLength', - 'minLength', - 'pattern', - 'maxItems', - 'minItems', - 'uniqueItems', - 'enum', - 'multipleOf', - 'format', - 'default' - ]; - for (const { key, childIterator } of visit(headerValue)) { if (key === 'schema') { this.visitSchema(targetHeader.schema.items, headerValue.items, childIterator); - } else if (schemaKeys.indexOf(key) !== -1) { + } else if (this.parameterTypeProperties.includes(key) || this.arrayProperties.includes(key)) { targetHeader.schema[key] = { value: headerValue[key], pointer: jsonPointer, recurse: true }; + } else if (key.startsWith('x-') && targetHeader[key] === undefined) { + targetHeader[key] = { value: headerValue[key], pointer: jsonPointer, recurse: true }; } } diff --git a/libraries/oai2-to-oai3/test/resources/conversion/ApiManagementClient-swagger.json b/libraries/oai2-to-oai3/test/resources/conversion/oai2/ApiManagementClient-swagger.json similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/ApiManagementClient-swagger.json rename to libraries/oai2-to-oai3/test/resources/conversion/oai2/ApiManagementClient-swagger.json diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai2/additionalProperties.json b/libraries/oai2-to-oai3/test/resources/conversion/oai2/additionalProperties.json new file mode 100644 index 0000000..b2dad77 --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai2/additionalProperties.json @@ -0,0 +1,375 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "AdditionalPropertiesClient", + "description": "Test Infrastructure for AutoRest" + }, + "host": "localhost:3000", + "schemes": [ + "http" + ], + "paths": { + "/additionalProperties/true": { + "put": { + "operationId": "Pets_CreateAPTrue", + "description": "Create a Pet which contains more properties than what is defined.", + "parameters": [ + { + "name": "createParameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PetAPTrue" + } + } + ], + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "schema": { + "$ref": "#/definitions/PetAPTrue" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + }, + "/additionalProperties/true-subclass": { + "put": { + "operationId": "Pets_CreateCatAPTrue", + "description": "Create a CatAPTrue which contains more properties than what is defined.", + "parameters": [ + { + "name": "createParameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CatAPTrue" + } + } + ], + "responses": { + "200": { + "description": "A CatAPTrue which contains more properties than what is defined.", + "schema": { + "$ref": "#/definitions/CatAPTrue" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + }, + "/additionalProperties/type/object": { + "put": { + "operationId": "Pets_CreateAPObject", + "description": "Create a Pet which contains more properties than what is defined.", + "parameters": [ + { + "name": "createParameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PetAPObject" + } + } + ], + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "schema": { + "$ref": "#/definitions/PetAPObject" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + }, + "/additionalProperties/type/string": { + "put": { + "operationId": "Pets_CreateAPString", + "description": "Create a Pet which contains more properties than what is defined.", + "parameters": [ + { + "name": "createParameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PetAPString" + } + } + ], + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "schema": { + "$ref": "#/definitions/PetAPString" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + }, + "/additionalProperties/in/properties": { + "put": { + "operationId": "Pets_CreateAPInProperties", + "description": "Create a Pet which contains more properties than what is defined.", + "parameters": [ + { + "name": "createParameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PetAPInProperties" + } + } + ], + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "schema": { + "$ref": "#/definitions/PetAPInProperties" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + }, + "/additionalProperties/in/properties/with/additionalProperties/string": { + "put": { + "operationId": "Pets_CreateAPInPropertiesWithAPString", + "description": "Create a Pet which contains more properties than what is defined.", + "parameters": [ + { + "name": "createParameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PetAPInPropertiesWithAPString" + } + } + ], + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "schema": { + "$ref": "#/definitions/PetAPInPropertiesWithAPString" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + } + }, + "definitions": { + "Error": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + }, + "PetAPTrue": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": { + "type": "object" + } + }, + "CatAPTrue": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/PetAPTrue" + } + ], + "properties": { + "friendly": { + "type": "boolean" + } + } + }, + "PetAPObject": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": { + "type": "object" + } + }, + "PetAPString": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": { + "type": "string" + } + }, + "PetAPInProperties": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + }, + "additionalProperties": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + } + }, + "PetAPInPropertiesWithAPString": { + "type": "object", + "required": [ + "id", + "@odata.location" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + }, + "@odata.location": { + "type": "string" + }, + "additionalProperties": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + }, + "additionalProperties": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai2/header.json b/libraries/oai2-to-oai3/test/resources/conversion/oai2/header.json new file mode 100644 index 0000000..ac470a5 --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai2/header.json @@ -0,0 +1,1037 @@ +{ + "swagger": "2.0", + "info": { + "title": "AutoRest Swagger BAT Header Service", + "description": "Test Infrastructure for AutoRest", + "version": "1.0.0" + }, + "host": "localhost:3000", + "schemes": [ + "http" + ], + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/header/param/existingkey": { + "post": { + "operationId": "header_paramExistingKey", + "description": "Send a post request with header value \"User-Agent\": \"overwrite\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header value \"User-Agent\": \"overwrite\"", + "name": "User-Agent", + "in": "header", + "type": "string", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/existingkey": { + "post": { + "operationId": "header_responseExistingKey", + "description": "Get a response with header value \"User-Agent\": \"overwrite\"", + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "User-Agent": { + "description": "response with header value \"User-Agent\": \"overwrite\"", + "type": "string" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/protectedkey": { + "post": { + "operationId": "header_paramProtectedKey", + "description": "Send a post request with header value \"Content-Type\": \"text/html\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header value \"Content-Type\": \"text/html\"", + "name": "Content-Type", + "in": "header", + "type": "string", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/protectedkey": { + "post": { + "operationId": "header_responseProtectedKey", + "description": "Get a response with header value \"Content-Type\": \"text/html\"", + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "Content-Type": { + "description": "response with header value \"Content-Type\": \"text/html\"", + "type": "string" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/integer": { + "post": { + "operationId": "header_paramInteger", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 1 or \"scenario\": \"negative\", \"value\": -2 ", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values 1 or -2", + "name": "value", + "in": "header", + "type": "integer", + "format": "int32", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/integer": { + "post": { + "operationId": "header_responseInteger", + "description": "Get a response with header value \"value\": 1 or -2", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 1 or -2", + "type": "integer", + "format": "int32" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/long": { + "post": { + "operationId": "header_paramLong", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 105 or \"scenario\": \"negative\", \"value\": -2 ", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values 105 or -2", + "name": "value", + "in": "header", + "type": "integer", + "format": "int64", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/long": { + "post": { + "operationId": "header_responseLong", + "description": "Get a response with header value \"value\": 105 or -2", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 105 or -2", + "type": "integer", + "format": "int64" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/float": { + "post": { + "operationId": "header_paramFloat", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 0.07 or \"scenario\": \"negative\", \"value\": -3.0", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values 0.07 or -3.0", + "name": "value", + "in": "header", + "type": "number", + "format": "float", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/float": { + "post": { + "operationId": "header_responseFloat", + "description": "Get a response with header value \"value\": 0.07 or -3.0", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 0.07 or -3.0", + "type": "number", + "format": "float" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/double": { + "post": { + "operationId": "header_paramDouble", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 7e120 or \"scenario\": \"negative\", \"value\": -3.0", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values 7e120 or -3.0", + "name": "value", + "in": "header", + "type": "number", + "format": "double", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/double": { + "post": { + "operationId": "header_responseDouble", + "description": "Get a response with header value \"value\": 7e120 or -3.0", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 7e120 or -3.0", + "type": "number", + "format": "double" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/bool": { + "post": { + "operationId": "header_paramBool", + "description": "Send a post request with header values \"scenario\": \"true\", \"value\": true or \"scenario\": \"false\", \"value\": false", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"true\" or \"false\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values true or false", + "name": "value", + "in": "header", + "type": "boolean", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/bool": { + "post": { + "operationId": "header_responseBool", + "description": "Get a response with header value \"value\": true or false", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"true\" or \"false\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": true or false", + "type": "boolean" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/string": { + "post": { + "operationId": "header_paramString", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"The quick brown fox jumps over the lazy dog\" or \"scenario\": \"null\", \"value\": null or \"scenario\": \"empty\", \"value\": \"\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values \"The quick brown fox jumps over the lazy dog\" or null or \"\"", + "name": "value", + "in": "header", + "type": "string", + "required": false + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/string": { + "post": { + "operationId": "header_responseString", + "description": "Get a response with header values \"The quick brown fox jumps over the lazy dog\" or null or \"\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"The quick brown fox jumps over the lazy dog\" or null or \"\"", + "type": "string" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/date": { + "post": { + "operationId": "header_paramDate", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"2010-01-01\" or \"scenario\": \"min\", \"value\": \"0001-01-01\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values \"2010-01-01\" or \"0001-01-01\"", + "name": "value", + "in": "header", + "type": "string", + "format": "date", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/date": { + "post": { + "operationId": "header_responseDate", + "description": "Get a response with header values \"2010-01-01\" or \"0001-01-01\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"2010-01-01\" or \"0001-01-01\"", + "type": "string", + "format": "date" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/datetime": { + "post": { + "operationId": "header_paramDatetime", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"2010-01-01T12:34:56Z\" or \"scenario\": \"min\", \"value\": \"0001-01-01T00:00:00Z\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values \"2010-01-01T12:34:56Z\" or \"0001-01-01T00:00:00Z\"", + "name": "value", + "in": "header", + "type": "string", + "format": "date-time", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/datetime": { + "post": { + "operationId": "header_responseDatetime", + "description": "Get a response with header values \"2010-01-01T12:34:56Z\" or \"0001-01-01T00:00:00Z\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"2010-01-01T12:34:56Z\" or \"0001-01-01T00:00:00Z\"", + "type": "string", + "format": "date-time" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/datetimerfc1123": { + "post": { + "operationId": "header_paramDatetimeRfc1123", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"scenario\": \"min\", \"value\": \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "name": "value", + "in": "header", + "type": "string", + "format": "date-time-rfc1123" + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/datetimerfc1123": { + "post": { + "operationId": "header_responseDatetimeRfc1123", + "description": "Get a response with header values \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "type": "string", + "format": "date-time-rfc1123" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/duration": { + "post": { + "operationId": "header_paramDuration", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"P123DT22H14M12.011S\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values \"P123DT22H14M12.011S\"", + "name": "value", + "in": "header", + "type": "string", + "format": "duration", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/duration": { + "post": { + "operationId": "header_responseDuration", + "description": "Get a response with header values \"P123DT22H14M12.011S\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"P123DT22H14M12.011S\"", + "type": "string", + "format": "duration" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/byte": { + "post": { + "operationId": "header_paramByte", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"啊齄丂狛狜隣郎隣兀﨩\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values \"啊齄丂狛狜隣郎隣兀﨩\"", + "name": "value", + "in": "header", + "type": "string", + "format": "byte", + "required": true + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/byte": { + "post": { + "operationId": "header_responseByte", + "description": "Get a response with header values \"啊齄丂狛狜隣郎隣兀﨩\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"啊齄丂狛狜隣郎隣兀﨩\"", + "type": "string", + "format": "byte" + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/param/prim/enum": { + "post": { + "operationId": "header_paramEnum", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"GREY\" or \"scenario\": \"null\", \"value\": null", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + }, + { + "description": "Send a post request with header values 'GREY' ", + "name": "value", + "in": "header", + "type": "string", + "enum": [ "White", "black", "GREY" ], + "x-ms-enum": { "name": "GreyscaleColors", "modelAsString": false}, + "required": false + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/response/prim/enum": { + "post": { + "operationId": "header_responseEnum", + "description": "Get a response with header values \"GREY\" or null", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "type": "string", + "required": true + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"GREY\" or null", + "type": "string", + "enum": [ "White", "black", "GREY" ], + "x-ms-enum": { "name": "GreyscaleColors", "modelAsString": false} + } + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0": { + "post": { + "operationId": "header_customRequestId", + "description": "Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request", + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response indicates that x-ms-client-request-id was successfuly received" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "Error": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/request-body-swagger.yaml b/libraries/oai2-to-oai3/test/resources/conversion/oai2/request-body-swagger.yaml similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/request-body-swagger.yaml rename to libraries/oai2-to-oai3/test/resources/conversion/oai2/request-body-swagger.yaml diff --git a/libraries/oai2-to-oai3/test/resources/conversion/swagger.yaml b/libraries/oai2-to-oai3/test/resources/conversion/oai2/swagger.yaml similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/swagger.yaml rename to libraries/oai2-to-oai3/test/resources/conversion/oai2/swagger.yaml diff --git a/libraries/oai2-to-oai3/test/resources/conversion/tiny-swagger.yaml b/libraries/oai2-to-oai3/test/resources/conversion/oai2/tiny-swagger.yaml similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/tiny-swagger.yaml rename to libraries/oai2-to-oai3/test/resources/conversion/oai2/tiny-swagger.yaml diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai2/xml-service.json b/libraries/oai2-to-oai3/test/resources/conversion/oai2/xml-service.json new file mode 100644 index 0000000..150ae70 --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai2/xml-service.json @@ -0,0 +1,1496 @@ +{ + "swagger": "2.0", + "info": { + "title": "AutoRest Swagger BAT XML Service", + "description": "Test Infrastructure for AutoRest Swagger BAT", + "version": "1.0.0" + }, + "host": "localhost:3000", + "schemes": [ + "http" + ], + "produces": [ + "application/xml" + ], + "consumes": [ + "application/xml" + ], + "paths": { + "/xml/complex-type-ref-no-meta": { + "get": { + "operationId": "xml_getComplexTypeRefNoMeta", + "description": "Get a complex type that has a ref to a complex type with no XML node", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty list.", + "schema": { + "$ref": "#/definitions/RootWithRefAndNoMeta" + } + } + } + }, + "put": { + "operationId": "xml_putComplexTypeRefNoMeta", + "description": "Puts a complex type that has a ref to a complex type with no XML node", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "model", + "in": "body", + "schema": { + "$ref": "#/definitions/RootWithRefAndNoMeta" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/complex-type-ref-with-meta": { + "get": { + "operationId": "xml_getComplexTypeRefWithMeta", + "description": "Get a complex type that has a ref to a complex type with XML node", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty list.", + "schema": { + "$ref": "#/definitions/RootWithRefAndMeta" + } + } + } + }, + "put": { + "operationId": "xml_putComplexTypeRefWithMeta", + "description": "Puts a complex type that has a ref to a complex type with XML node", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "model", + "in": "body", + "schema": { + "$ref": "#/definitions/RootWithRefAndMeta" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/simple": { + "get": { + "operationId": "xml_getSimple", + "description": "Get a simple XML document", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The simple XML document", + "schema": { + "$ref": "#/definitions/Slideshow" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "put": { + "operationId": "xml_putSimple", + "description": "Put a simple XML document", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "slideshow", + "in": "body", + "schema": { + "$ref": "#/definitions/Slideshow" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/xml/wrapped-lists": { + "get": { + "operationId": "xml_getWrappedLists", + "description": "Get an XML document with multiple wrapped lists", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The XML document with multiple wrapped lists", + "schema": { + "$ref": "#/definitions/AppleBarrel" + } + } + } + }, + "put": { + "operationId": "xml_putWrappedLists", + "description": "Put an XML document with multiple wrapped lists", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "wrappedLists", + "in": "body", + "schema": { + "$ref": "#/definitions/AppleBarrel" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/xml/headers": { + "get": { + "operationId": "xml_getHeaders", + "description": "Get strongly-typed response headers.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The response header.", + "headers": { + "Custom-Header": { + "description": "A custom response header.", + "type": "string" + } + } + } + } + } + }, + "/xml/empty-list": { + "get": { + "operationId": "xml_getEmptyList", + "description": "Get an empty list.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty list.", + "schema": { + "$ref": "#/definitions/Slideshow" + } + } + } + }, + "put": { + "operationId": "xml_putEmptyList", + "description": "Puts an empty list.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "slideshow", + "in": "body", + "schema": { + "$ref": "#/definitions/Slideshow" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/empty-wrapped-lists": { + "get": { + "operationId": "xml_getEmptyWrappedLists", + "description": "Gets some empty wrapped lists.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty lists.", + "schema": { + "$ref": "#/definitions/AppleBarrel" + } + } + } + }, + "put": { + "operationId": "xml_putEmptyWrappedLists", + "description": "Puts some empty wrapped lists.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "appleBarrel", + "in": "body", + "schema": { + "$ref": "#/definitions/AppleBarrel" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/root-list": { + "get": { + "operationId": "xml_getRootList", + "description": "Gets a list as the root element.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The root list.", + "schema": { + "type": "array", + "xml": { + "name": "bananas" + }, + "items": { + "$ref": "#/definitions/Banana" + } + } + } + } + }, + "put": { + "operationId": "xml_putRootList", + "description": "Puts a list as the root element.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "bananas", + "in": "body", + "schema": { + "type": "array", + "xml": { + "name": "bananas", + "wrapped": true + }, + "items": { + "$ref": "#/definitions/Banana" + } + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/root-list-single-item": { + "get": { + "operationId": "xml_getRootListSingleItem", + "description": "Gets a list with a single item.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The root list.", + "schema": { + "type": "array", + "xml": { + "name": "bananas" + }, + "items": { + "$ref": "#/definitions/Banana" + } + } + } + } + }, + "put": { + "operationId": "xml_putRootListSingleItem", + "description": "Puts a list with a single item.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "bananas", + "in": "body", + "schema": { + "type": "array", + "xml": { + "name": "bananas", + "wrapped": true + }, + "items": { + "$ref": "#/definitions/Banana" + } + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/empty-root-list": { + "get": { + "operationId": "xml_getEmptyRootList", + "description": "Gets an empty list as the root element.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The root list.", + "schema": { + "type": "array", + "xml": { + "name": "bananas" + }, + "items": { + "$ref": "#/definitions/Banana" + } + } + } + } + }, + "put": { + "operationId": "xml_putEmptyRootList", + "description": "Puts an empty list as the root element.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "bananas", + "in": "body", + "schema": { + "type": "array", + "xml": { + "name": "bananas", + "wrapped": true + }, + "items": { + "$ref": "#/definitions/Banana" + } + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/empty-child-element": { + "get": { + "operationId": "xml_getEmptyChildElement", + "description": "Gets an XML document with an empty child element.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The unknown banana.", + "schema": { + "$ref": "#/definitions/Banana" + } + } + } + }, + "put": { + "operationId": "xml_putEmptyChildElement", + "description": "Puts a value with an empty child element.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "banana", + "in": "body", + "schema": { + "$ref": "#/definitions/Banana" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/?comp=list": { + "get": { + "operationId": "xml_listContainers", + "description": "Lists containers in a storage account.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "type": "string", + "enum": [ + "list" + ], + "required": true + } + ], + "responses": { + "200": { + "description": "A list of containers.", + "schema": { + "$ref": "#/definitions/ListContainersResponse" + } + } + } + } + }, + "/xml/?comp=properties&restype=service": { + "get": { + "operationId": "xml_getServiceProperties", + "description": "Gets storage service properties.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "type": "string", + "enum": [ + "properties" + ], + "required": true + }, + { + "name": "restype", + "in": "query", + "type": "string", + "enum": [ + "service" + ], + "required": true + } + ], + "responses": { + "200": { + "description": "The storage service properties.", + "schema": { + "$ref": "#/definitions/StorageServiceProperties" + } + } + } + }, + "put": { + "operationId": "xml_putServiceProperties", + "description": "Puts storage service properties.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "type": "string", + "enum": [ + "properties" + ], + "required": true + }, + { + "name": "restype", + "in": "query", + "type": "string", + "enum": [ + "service" + ], + "required": true + }, + { + "name": "properties", + "in": "body", + "schema": { + "$ref": "#/definitions/StorageServiceProperties" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/mycontainer?comp=acl&restype=container": { + "get": { + "operationId": "xml_getAcls", + "description": "Gets storage ACLs for a container.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "type": "string", + "enum": [ + "acl" + ], + "required": true + }, + { + "name": "restype", + "in": "query", + "type": "string", + "enum": [ + "container" + ], + "required": true + } + ], + "responses": { + "200": { + "description": "The storage ACLs.", + "schema": { + "$ref": "#/definitions/SignedIdentifiers" + } + } + } + }, + "put": { + "operationId": "xml_putAcls", + "description": "Puts storage ACLs for a container.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "type": "string", + "enum": [ + "acl" + ], + "required": true + }, + { + "name": "restype", + "in": "query", + "type": "string", + "enum": [ + "container" + ], + "required": true + }, + { + "name": "properties", + "in": "body", + "schema": { + "$ref": "#/definitions/SignedIdentifiers" + }, + "required": true + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + } + } + }, + "/xml/mycontainer?comp=list&restype=container": { + "get": { + "operationId": "xml_listBlobs", + "description": "Lists blobs in a storage container.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "type": "string", + "enum": [ + "list" + ], + "required": true + }, + { + "name": "restype", + "in": "query", + "type": "string", + "enum": [ + "container" + ], + "required": true + } + ], + "responses": { + "200": { + "description": "A list of containers.", + "schema": { + "$ref": "#/definitions/ListBlobsResponse" + } + } + } + } + } + }, + "definitions": { + "Error": { + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + }, + "Slide": { + "type": "object", + "description": "A slide in a slideshow", + "properties": { + "type": { + "type": "string", + "xml": { + "attribute": true + } + }, + "title": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "type": "string", + "xml": { + "name": "item" + } + } + } + }, + "xml": { + "name": "slide" + } + }, + "Slideshow": { + "type": "object", + "description": "Data about a slideshow", + "xml": { + "name": "slideshow" + }, + "properties": { + "title": { + "type": "string", + "xml": { + "attribute": true + } + }, + "date": { + "type": "string", + "xml": { + "attribute": true + } + }, + "author": { + "type": "string", + "xml": { + "attribute": true + } + }, + "slides": { + "type": "array", + "items": { + "$ref": "#/definitions/Slide" + } + } + } + }, + "AppleBarrel": { + "type": "object", + "description": "A barrel of apples.", + "properties": { + "GoodApples": { + "type": "array", + "items": { + "type": "string", + "xml": { + "name": "Apple" + } + }, + "xml": { + "wrapped": true + } + }, + "BadApples": { + "type": "array", + "items": { + "type": "string", + "xml": { + "name": "Apple" + } + }, + "xml": { + "wrapped": true + } + } + } + }, + "Banana": { + "type": "object", + "description": "A banana.", + "properties": { + "name": { + "type": "string", + "xml": { + "name": "name" + } + }, + "flavor": { + "type": "string", + "xml": { + "name": "flavor" + } + }, + "expiration": { + "description": "The time at which you should reconsider eating this banana", + "type": "string", + "format": "date-time", + "xml": { + "name": "expiration" + } + } + }, + "xml": { + "name": "banana" + } + }, + "Container": { + "type": "object", + "required": [ + "Name", + "Properties" + ], + "description": "An Azure Storage container", + "properties": { + "Name": { + "type": "string" + }, + "Properties": { + "$ref": "#/definitions/ContainerProperties" + }, + "Metadata": { + "$ref": "#/definitions/Metadata" + } + } + }, + "ContainerProperties": { + "type": "object", + "required": [ + "Last-Modified", + "Etag" + ], + "description": "Properties of a container", + "properties": { + "Last-Modified": { + "type": "string", + "format": "date-time-rfc1123" + }, + "Etag": { + "type": "string", + "format": "etag" + }, + "LeaseStatus": { + "$ref": "#/definitions/LeaseStatus" + }, + "LeaseState": { + "$ref": "#/definitions/LeaseState" + }, + "LeaseDuration": { + "$ref": "#/definitions/LeaseDuration" + }, + "PublicAccess": { + "$ref": "#/definitions/PublicAccessType" + } + } + }, + "ListContainersResponse": { + "xml": { + "name": "EnumerationResults" + }, + "description": "An enumeration of containers", + "type": "object", + "required": [ + "ServiceEndpoint", + "Prefix", + "MaxResults", + "NextMarker" + ], + "properties": { + "ServiceEndpoint": { + "type": "string", + "xml": { + "attribute": true + } + }, + "Prefix": { + "type": "string" + }, + "Marker": { + "type": "string" + }, + "MaxResults": { + "type": "integer" + }, + "Containers": { + "xml": { + "wrapped": true + }, + "type": "array", + "items": { + "$ref": "#/definitions/Container" + } + }, + "NextMarker": { + "type": "string" + } + } + }, + "CorsRule": { + "description": "CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain", + "type": "object", + "required": [ + "AllowedOrigins", + "AllowedMethods", + "AllowedHeaders", + "ExposedHeaders", + "MaxAgeInSeconds" + ], + "properties": { + "AllowedOrigins": { + "description": "The origin domains that are permitted to make a request against the storage service via CORS. The origin domain is the domain from which the request originates. Note that the origin must be an exact case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' to allow all origin domains to make requests via CORS.", + "type": "string" + }, + "AllowedMethods": { + "description": "The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated)", + "type": "string" + }, + "AllowedHeaders": { + "description": "the request headers that the origin domain may specify on the CORS request.", + "type": "string" + }, + "ExposedHeaders": { + "description": "The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer", + "type": "string" + }, + "MaxAgeInSeconds": { + "description": "The maximum amount time that a browser should cache the preflight OPTIONS request.", + "type": "integer", + "minimum": 0 + } + }, + "xml": { + "name": "CorsRule" + } + }, + "Blob": { + "description": "An Azure Storage blob", + "type": "object", + "required": [ + "Name", + "Deleted", + "Snapshot", + "Properties" + ], + "properties": { + "Name": { + "type": "string" + }, + "Deleted": { + "type": "boolean" + }, + "Snapshot": { + "type": "string" + }, + "Properties": { + "$ref": "#/definitions/BlobProperties" + }, + "Metadata": { + "$ref": "#/definitions/Metadata" + } + }, + "xml": { + "name": "Blob" + } + }, + "BlobProperties": { + "description": "Properties of a blob", + "type": "object", + "required": [ + "Etag", + "Last-Modified" + ], + "properties": { + "Last-Modified": { + "type": "string", + "format": "date-time-rfc1123" + }, + "Etag": { + "type": "string", + "format": "etag" + }, + "Content-Length": { + "type": "integer", + "format": "int64", + "description": "Size in bytes" + }, + "Content-Type": { + "type": "string" + }, + "Content-Encoding": { + "type": "string" + }, + "Content-Language": { + "type": "string" + }, + "Content-MD5": { + "type": "string" + }, + "Content-Disposition": { + "type": "string" + }, + "Cache-Control": { + "type": "string" + }, + "x-ms-blob-sequence-number": { + "x-ms-client-name": "blobSequenceNumber", + "type": "integer" + }, + "BlobType": { + "type": "string", + "enum": [ + "BlockBlob", + "PageBlob", + "AppendBlob" + ], + "x-ms-enum": { + "name": "BlobType", + "modelAsString": false + } + }, + "LeaseStatus": { + "$ref": "#/definitions/LeaseStatus" + }, + "LeaseState": { + "$ref": "#/definitions/LeaseState" + }, + "LeaseDuration": { + "$ref": "#/definitions/LeaseDuration" + }, + "CopyId": { + "type": "string" + }, + "CopyStatus": { + "$ref": "#/definitions/CopyStatus" + }, + "CopySource": { + "type": "string" + }, + "CopyProgress": { + "type": "string" + }, + "CopyCompletionTime": { + "type": "string", + "format": "date-time-rfc1123" + }, + "CopyStatusDescription": { + "type": "string" + }, + "ServerEncrypted": { + "type": "boolean" + }, + "IncrementalCopy": { + "type": "boolean" + }, + "DestinationSnapshot": { + "type": "string" + }, + "DeletedTime": { + "type": "string", + "format": "date-time-rfc1123" + }, + "RemainingRetentionDays": { + "type": "integer" + }, + "AccessTier": { + "$ref": "#/definitions/AccessTier" + }, + "AccessTierInferred": { + "type": "boolean" + }, + "ArchiveStatus": { + "$ref": "#/definitions/ArchiveStatus" + } + } + }, + "Logging": { + "description": "Azure Analytics Logging settings.", + "type": "object", + "required": [ + "Version", + "Delete", + "Read", + "Write", + "RetentionPolicy" + ], + "properties": { + "Version": { + "description": "The version of Storage Analytics to configure.", + "type": "string" + }, + "Delete": { + "description": "Indicates whether all delete requests should be logged.", + "type": "boolean" + }, + "Read": { + "description": "Indicates whether all read requests should be logged.", + "type": "boolean" + }, + "Write": { + "description": "Indicates whether all write requests should be logged.", + "type": "boolean" + }, + "RetentionPolicy": { + "$ref": "#/definitions/RetentionPolicy" + } + } + }, + "Metadata": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "Metrics": { + "description": "", + "required": [ + "Enabled" + ], + "properties": { + "Version": { + "description": "The version of Storage Analytics to configure.", + "type": "string" + }, + "Enabled": { + "description": "Indicates whether metrics are enabled for the Blob service.", + "type": "boolean" + }, + "IncludeAPIs": { + "description": "Indicates whether metrics should generate summary statistics for called API operations.", + "type": "boolean" + }, + "RetentionPolicy": { + "$ref": "#/definitions/RetentionPolicy" + } + } + }, + "ListBlobsResponse": { + "xml": { + "name": "EnumerationResults" + }, + "description": "An enumeration of blobs", + "type": "object", + "required": [ + "ServiceEndpoint", + "ContainerName", + "Prefix", + "Marker", + "MaxResults", + "Delimiter", + "Blobs", + "NextMarker" + ], + "properties": { + "ServiceEndpoint": { + "type": "string", + "xml": { + "attribute": true + } + }, + "ContainerName": { + "type": "string", + "xml": { + "attribute": true + } + }, + "Prefix": { + "type": "string" + }, + "Marker": { + "type": "string" + }, + "MaxResults": { + "type": "integer" + }, + "Delimiter": { + "type": "string" + }, + "Blobs": { + "$ref": "#/definitions/Blobs" + }, + "NextMarker": { + "type": "string" + } + } + }, + "Blobs": { + "type": "object", + "properties": { + "BlobPrefix": { + "type": "array", + "items": { + "$ref": "#/definitions/BlobPrefix" + } + }, + "Blob": { + "type": "array", + "items": { + "$ref": "#/definitions/Blob" + } + } + } + }, + "BlobPrefix": { + "type": "object", + "required": [ + "Name" + ], + "properties": { + "Name": { + "type": "string" + } + } + }, + "PublicAccessType": { + "type": "string", + "enum": [ + "container", + "blob" + ], + "x-ms-enum": { + "name": "PublicAccessType", + "modelAsString": true + } + }, + "CopyStatus": { + "type": "string", + "enum": [ + "pending", + "success", + "aborted", + "failed" + ], + "x-ms-enum": { + "name": "CopyStatusType", + "modelAsString": false + } + }, + "LeaseDuration": { + "type": "string", + "enum": [ + "infinite", + "fixed" + ], + "x-ms-enum": { + "name": "LeaseDurationType", + "modelAsString": false + } + }, + "LeaseState": { + "type": "string", + "enum": [ + "available", + "leased", + "expired", + "breaking", + "broken" + ], + "x-ms-enum": { + "name": "LeaseStateType", + "modelAsString": false + } + }, + "LeaseStatus": { + "type": "string", + "enum": [ + "locked", + "unlocked" + ], + "x-ms-enum": { + "name": "LeaseStatusType", + "modelAsString": false + } + }, + "AccessPolicy": { + "type": "object", + "required": [ + "Start", + "Expiry", + "Permission" + ], + "description": "An Access policy", + "properties": { + "Start": { + "description": "the date-time the policy is active", + "type": "string", + "format": "date-time" + }, + "Expiry": { + "description": "the date-time the policy expires", + "type": "string", + "format": "date-time" + }, + "Permission": { + "description": "the permissions for the acl policy", + "type": "string" + } + } + }, + "AccessTier": { + "type": "string", + "enum": [ + "P4", + "P6", + "P10", + "P20", + "P30", + "P40", + "P50", + "Hot", + "Cool", + "Archive" + ], + "x-ms-enum": { + "name": "AccessTier", + "modelAsString": true + } + }, + "ArchiveStatus": { + "type": "string", + "enum": [ + "rehydrate-pending-to-hot", + "rehydrate-pending-to-cool" + ], + "x-ms-enum": { + "name": "ArchiveStatus", + "modelAsString": true + } + }, + "RetentionPolicy": { + "description": "the retention policy", + "type": "object", + "required": [ + "Enabled" + ], + "properties": { + "Enabled": { + "description": "Indicates whether a retention policy is enabled for the storage service", + "type": "boolean" + }, + "Days": { + "description": "Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this value will be deleted", + "type": "integer", + "minimum": 1 + } + } + }, + "SignedIdentifier": { + "description": "signed identifier", + "type": "object", + "required": [ + "Id", + "AccessPolicy" + ], + "properties": { + "Id": { + "type": "string", + "description": "a unique id" + }, + "AccessPolicy": { + "description": "The access policy", + "$ref": "#/definitions/AccessPolicy" + } + }, + "xml": { + "name": "SignedIdentifier" + } + }, + "SignedIdentifiers": { + "description": "a collection of signed identifiers", + "type": "array", + "items": { + "$ref": "#/definitions/SignedIdentifier" + }, + "xml": { + "wrapped": true, + "name": "SignedIdentifiers" + } + }, + "StorageServiceProperties": { + "description": "Storage Service Properties.", + "type": "object", + "properties": { + "Logging": { + "description": "Azure Analytics Logging settings", + "$ref": "#/definitions/Logging" + }, + "HourMetrics": { + "description": "A summary of request statistics grouped by API in hourly aggregates for blobs", + "$ref": "#/definitions/Metrics" + }, + "MinuteMetrics": { + "description": "a summary of request statistics grouped by API in minute aggregates for blobs", + "$ref": "#/definitions/Metrics" + }, + "Cors": { + "description": "The set of CORS rules.", + "type": "array", + "items": { + "$ref": "#/definitions/CorsRule" + }, + "xml": { + "wrapped": true + } + }, + "DefaultServiceVersion": { + "description": "The default version to use for requests to the Blob service if an incoming request's version is not specified. Possible values include version 2008-10-27 and all more recent versions", + "type": "string" + }, + "DeleteRetentionPolicy": { + "description": "The Delete Retention Policy for the service", + "$ref": "#/definitions/RetentionPolicy" + } + } + }, + "ComplexTypeNoMeta": { + "description": "I am a complex type with no XML node", + "type": "object", + "properties":{ + "ID": { + "description": "The id of the res", + "type": "string" + } + } + }, + "ComplexTypeWithMeta": { + "description": "I am a complex type with XML node", + "type": "object", + "properties":{ + "ID": { + "description": "The id of the res", + "type": "string" + } + }, + "xml": { + "name": "XMLComplexTypeWithMeta" + } + }, + "RootWithRefAndNoMeta": { + "description": "I am root, and I ref a model with no meta", + "type": "object", + "properties":{ + "RefToModel": { + "description": "XML will use RefToModel", + "$ref": "#/definitions/ComplexTypeNoMeta" + }, + "Something": { + "description": "Something else (just to avoid flattening)", + "type": "string" + } + } + }, + "RootWithRefAndMeta": { + "description": "I am root, and I ref a model WITH meta", + "type": "object", + "properties":{ + "RefToModel": { + "description": "XML will use XMLComplexTypeWithMeta", + "$ref": "#/definitions/ComplexTypeWithMeta" + }, + "Something": { + "description": "Something else (just to avoid flattening)", + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai2/xms-error-responses.json b/libraries/oai2-to-oai3/test/resources/conversion/oai2/xms-error-responses.json new file mode 100644 index 0000000..65b692c --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai2/xms-error-responses.json @@ -0,0 +1,235 @@ +{ + "swagger": "2.0", + "info": { + "version": "0.0.0", + "title": "XMS Error Response Extensions", + "description": "XMS Error Response Extensions" + }, + "host": "localhost", + "schemes": [ + "http" + ], + "paths": { + "/errorStatusCodes/Pets/{petId}/GetPet": { + "get": { + "operationId": "Pet_GetPetById", + "description": "Gets pets by id.", + "parameters": [ + { + "name": "petId", + "in": "path", + "required": true, + "type": "string", + "description": "pet id" + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/Pet" + } + }, + "202": { + "description": "something something dark side" + }, + "404": { + "description": "Not found", + "schema": { + "$ref": "#/definitions/NotFoundErrorBase" + }, + "x-ms-error-response": true + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + }, + "x-ms-error-response": true + }, + "501": { + "description": "Some unexpected error", + "schema": { + "type": "integer" + }, + "x-ms-error-response": true + }, + "default": { + "description": "default stuff" + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + }, + "/errorStatusCodes/Pets/doSomething/{whatAction}": { + "post": { + "operationId": "Pet_DoSomething", + "description": "Asks pet to do something", + "parameters": [ + { + "name": "whatAction", + "in": "path", + "required": true, + "type": "string", + "description": "what action the pet should do" + } + ], + "responses": { + "200": { + "description": "action performed", + "schema": { + "$ref": "#/definitions/PetAction" + } + }, + "500": { + "description": "something bad happened", + "schema": { + "$ref": "#/definitions/PetActionError" + }, + "x-ms-error-response": true + }, + "default": { + "description": "default stuff", + "schema": { + "$ref": "#/definitions/PetActionError" + } + } + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ] + } + } + }, + "definitions": { + "Pet": { + "allOf": [ + { + "$ref": "#/definitions/Animal" + } + ], + "properties": { + "name": { + "type": "string", + "readOnly": true, + "description": "Gets the Pet by id." + } + } + }, + "NotFoundErrorBase": { + "properties": { + "reason": { + "type": "string" + }, + "whatNotFound": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/definitions/BaseError" + } + ], + "required": [ + "whatNotFound" + ], + "discriminator": "whatNotFound" + }, + "BaseError": { + "properties": { + "someBaseProp": { + "type": "string" + } + } + }, + "LinkNotFound": { + "properties": { + "whatSubAddress": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/definitions/NotFoundErrorBase" + } + ], + "x-ms-discriminator-value": "InvalidResourceLink" + }, + "AnimalNotFound": { + "properties": { + "name": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/definitions/NotFoundErrorBase" + } + ] + }, + "Animal": { + "properties": { + "aniType": { + "type": "string" + } + } + }, + "PetAction": { + "properties": { + "actionResponse": { + "type": "string", + "description": "action feedback" + } + } + }, + "PetActionError": { + "properties": { + "errorType": { + "type": "string" + }, + "errorMessage": { + "type": "string", + "description": "the error message" + } + }, + "required": [ + "errorType" + ], + "discriminator": "errorType" + }, + "PetSadError": { + "allOf": [ + { + "$ref": "#/definitions/PetActionError" + } + ], + "properties": { + "reason": { + "type": "string", + "description": "why is the pet sad" + } + } + }, + "PetHungryOrThirstyError": { + "allOf": [ + { + "$ref": "#/definitions/PetSadError" + } + ], + "properties": { + "hungryOrThirsty": { + "type": "string", + "description": "is the pet hungry or thirsty or both" + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/ApiManagementClient-openapi.json b/libraries/oai2-to-oai3/test/resources/conversion/oai3/ApiManagementClient-openapi.json similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/ApiManagementClient-openapi.json rename to libraries/oai2-to-oai3/test/resources/conversion/oai3/ApiManagementClient-openapi.json diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai3/additionalProperties.json b/libraries/oai2-to-oai3/test/resources/conversion/oai3/additionalProperties.json new file mode 100644 index 0000000..bffdc01 --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai3/additionalProperties.json @@ -0,0 +1,402 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost:3000/" + } + ], + "info": { + "version": "1.0.0", + "title": "AdditionalPropertiesClient", + "description": "Test Infrastructure for AutoRest" + }, + "paths": { + "/additionalProperties/true": { + "put": { + "operationId": "Pets_CreateAPTrue", + "description": "Create a Pet which contains more properties than what is defined.", + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPTrue" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "createParameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPTrue" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/additionalProperties/true-subclass": { + "put": { + "operationId": "Pets_CreateCatAPTrue", + "description": "Create a CatAPTrue which contains more properties than what is defined.", + "responses": { + "200": { + "description": "A CatAPTrue which contains more properties than what is defined.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CatAPTrue" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "createParameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CatAPTrue" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/additionalProperties/type/object": { + "put": { + "operationId": "Pets_CreateAPObject", + "description": "Create a Pet which contains more properties than what is defined.", + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPObject" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "createParameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPObject" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/additionalProperties/type/string": { + "put": { + "operationId": "Pets_CreateAPString", + "description": "Create a Pet which contains more properties than what is defined.", + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPString" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "createParameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPString" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/additionalProperties/in/properties": { + "put": { + "operationId": "Pets_CreateAPInProperties", + "description": "Create a Pet which contains more properties than what is defined.", + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPInProperties" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "createParameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPInProperties" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/additionalProperties/in/properties/with/additionalProperties/string": { + "put": { + "operationId": "Pets_CreateAPInPropertiesWithAPString", + "description": "Create a Pet which contains more properties than what is defined.", + "responses": { + "200": { + "description": "A Pet which contains more properties than what is defined.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPInPropertiesWithAPString" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "createParameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAPInPropertiesWithAPString" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + } + }, + "components": { + "schemas": { + "Error": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + }, + "PetAPTrue": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": { + "type": "object" + } + }, + "CatAPTrue": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/PetAPTrue" + } + ], + "properties": { + "friendly": { + "type": "boolean" + } + } + }, + "PetAPObject": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": { + "type": "object" + } + }, + "PetAPString": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + } + }, + "additionalProperties": { + "type": "string" + } + }, + "PetAPInProperties": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + }, + "additionalProperties": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + } + }, + "PetAPInPropertiesWithAPString": { + "type": "object", + "required": [ + "id", + "@odata.location" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "status": { + "type": "boolean", + "readOnly": true + }, + "@odata.location": { + "type": "string" + }, + "additionalProperties": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + }, + "additionalProperties": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai3/header.json b/libraries/oai2-to-oai3/test/resources/conversion/oai3/header.json new file mode 100644 index 0000000..687fdcd --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai3/header.json @@ -0,0 +1,1268 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost:3000/" + } + ], + "info": { + "version": "1.0.0", + "title": "AutoRest Swagger BAT Header Service", + "description": "Test Infrastructure for AutoRest" + }, + "paths": { + "/header/param/existingkey": { + "post": { + "operationId": "header_paramExistingKey", + "description": "Send a post request with header value \"User-Agent\": \"overwrite\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header value \"User-Agent\": \"overwrite\"", + "name": "User-Agent", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/existingkey": { + "post": { + "operationId": "header_responseExistingKey", + "description": "Get a response with header value \"User-Agent\": \"overwrite\"", + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "User-Agent": { + "description": "response with header value \"User-Agent\": \"overwrite\"", + "schema": { + "type": "string" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/protectedkey": { + "post": { + "operationId": "header_paramProtectedKey", + "description": "Send a post request with header value \"Content-Type\": \"text/html\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header value \"Content-Type\": \"text/html\"", + "name": "Content-Type", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/protectedkey": { + "post": { + "operationId": "header_responseProtectedKey", + "description": "Get a response with header value \"Content-Type\": \"text/html\"", + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "Content-Type": { + "description": "response with header value \"Content-Type\": \"text/html\"", + "schema": { + "type": "string" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/integer": { + "post": { + "operationId": "header_paramInteger", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 1 or \"scenario\": \"negative\", \"value\": -2 ", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values 1 or -2", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/integer": { + "post": { + "operationId": "header_responseInteger", + "description": "Get a response with header value \"value\": 1 or -2", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 1 or -2", + "schema": { + "type": "integer", + "format": "int32" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/long": { + "post": { + "operationId": "header_paramLong", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 105 or \"scenario\": \"negative\", \"value\": -2 ", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values 105 or -2", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/long": { + "post": { + "operationId": "header_responseLong", + "description": "Get a response with header value \"value\": 105 or -2", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 105 or -2", + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/float": { + "post": { + "operationId": "header_paramFloat", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 0.07 or \"scenario\": \"negative\", \"value\": -3.0", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values 0.07 or -3.0", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "number", + "format": "float" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/float": { + "post": { + "operationId": "header_responseFloat", + "description": "Get a response with header value \"value\": 0.07 or -3.0", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 0.07 or -3.0", + "schema": { + "type": "number", + "format": "float" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/double": { + "post": { + "operationId": "header_paramDouble", + "description": "Send a post request with header values \"scenario\": \"positive\", \"value\": 7e120 or \"scenario\": \"negative\", \"value\": -3.0", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values 7e120 or -3.0", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "number", + "format": "double" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/double": { + "post": { + "operationId": "header_responseDouble", + "description": "Get a response with header value \"value\": 7e120 or -3.0", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"positive\" or \"negative\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": 7e120 or -3.0", + "schema": { + "type": "number", + "format": "double" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/bool": { + "post": { + "operationId": "header_paramBool", + "description": "Send a post request with header values \"scenario\": \"true\", \"value\": true or \"scenario\": \"false\", \"value\": false", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"true\" or \"false\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values true or false", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/bool": { + "post": { + "operationId": "header_responseBool", + "description": "Get a response with header value \"value\": true or false", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"true\" or \"false\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header value \"value\": true or false", + "schema": { + "type": "boolean" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/string": { + "post": { + "operationId": "header_paramString", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"The quick brown fox jumps over the lazy dog\" or \"scenario\": \"null\", \"value\": null or \"scenario\": \"empty\", \"value\": \"\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values \"The quick brown fox jumps over the lazy dog\" or null or \"\"", + "name": "value", + "in": "header", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/string": { + "post": { + "operationId": "header_responseString", + "description": "Get a response with header values \"The quick brown fox jumps over the lazy dog\" or null or \"\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"The quick brown fox jumps over the lazy dog\" or null or \"\"", + "schema": { + "type": "string" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/date": { + "post": { + "operationId": "header_paramDate", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"2010-01-01\" or \"scenario\": \"min\", \"value\": \"0001-01-01\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values \"2010-01-01\" or \"0001-01-01\"", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "string", + "format": "date" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/date": { + "post": { + "operationId": "header_responseDate", + "description": "Get a response with header values \"2010-01-01\" or \"0001-01-01\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"2010-01-01\" or \"0001-01-01\"", + "schema": { + "type": "string", + "format": "date" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/datetime": { + "post": { + "operationId": "header_paramDatetime", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"2010-01-01T12:34:56Z\" or \"scenario\": \"min\", \"value\": \"0001-01-01T00:00:00Z\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values \"2010-01-01T12:34:56Z\" or \"0001-01-01T00:00:00Z\"", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "string", + "format": "date-time" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/datetime": { + "post": { + "operationId": "header_responseDatetime", + "description": "Get a response with header values \"2010-01-01T12:34:56Z\" or \"0001-01-01T00:00:00Z\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"2010-01-01T12:34:56Z\" or \"0001-01-01T00:00:00Z\"", + "schema": { + "type": "string", + "format": "date-time" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/datetimerfc1123": { + "post": { + "operationId": "header_paramDatetimeRfc1123", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"scenario\": \"min\", \"value\": \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "name": "value", + "in": "header", + "schema": { + "type": "string", + "format": "date-time-rfc1123" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/datetimerfc1123": { + "post": { + "operationId": "header_responseDatetimeRfc1123", + "description": "Get a response with header values \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"min\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"Wed, 01 Jan 2010 12:34:56 GMT\" or \"Mon, 01 Jan 0001 00:00:00 GMT\"", + "schema": { + "type": "string", + "format": "date-time-rfc1123" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/duration": { + "post": { + "operationId": "header_paramDuration", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"P123DT22H14M12.011S\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values \"P123DT22H14M12.011S\"", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "string", + "format": "duration" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/duration": { + "post": { + "operationId": "header_responseDuration", + "description": "Get a response with header values \"P123DT22H14M12.011S\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"P123DT22H14M12.011S\"", + "schema": { + "type": "string", + "format": "duration" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/byte": { + "post": { + "operationId": "header_paramByte", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"啊齄丂狛狜隣郎隣兀﨩\"", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values \"啊齄丂狛狜隣郎隣兀﨩\"", + "name": "value", + "in": "header", + "required": true, + "schema": { + "type": "string", + "format": "byte" + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/byte": { + "post": { + "operationId": "header_responseByte", + "description": "Get a response with header values \"啊齄丂狛狜隣郎隣兀﨩\"", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"啊齄丂狛狜隣郎隣兀﨩\"", + "schema": { + "type": "string", + "format": "byte" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/param/prim/enum": { + "post": { + "operationId": "header_paramEnum", + "description": "Send a post request with header values \"scenario\": \"valid\", \"value\": \"GREY\" or \"scenario\": \"null\", \"value\": null", + "tags": [ + "Header Operations" + ], + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Send a post request with header values 'GREY' ", + "name": "value", + "in": "header", + "required": false, + "schema": { + "x-ms-enum": { + "name": "GreyscaleColors", + "modelAsString": false + }, + "type": "string", + "enum": [ + "White", + "black", + "GREY" + ] + } + } + ], + "responses": { + "200": { + "description": "Empty Response" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/response/prim/enum": { + "post": { + "operationId": "header_responseEnum", + "description": "Get a response with header values \"GREY\" or null", + "parameters": [ + { + "description": "Send a post request with header values \"scenario\": \"valid\" or \"null\" or \"empty\"", + "name": "scenario", + "in": "header", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response", + "headers": { + "value": { + "description": "response with header values \"GREY\" or null", + "x-ms-enum": { + "name": "GreyscaleColors", + "modelAsString": false + }, + "schema": { + "type": "string", + "enum": [ + "White", + "black", + "GREY" + ] + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + }, + "/header/custom/x-ms-client-request-id/9C4D50EE-2D56-4CD3-8152-34347DC9F2B0": { + "post": { + "operationId": "header_customRequestId", + "description": "Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request", + "tags": [ + "Header Operations" + ], + "responses": { + "200": { + "description": "Empty Response indicates that x-ms-client-request-id was successfuly received" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Error": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/openapi.yaml b/libraries/oai2-to-oai3/test/resources/conversion/oai3/openapi.yaml similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/openapi.yaml rename to libraries/oai2-to-oai3/test/resources/conversion/oai3/openapi.yaml diff --git a/libraries/oai2-to-oai3/test/resources/conversion/request-body-openapi.yaml b/libraries/oai2-to-oai3/test/resources/conversion/oai3/request-body-openapi.yaml similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/request-body-openapi.yaml rename to libraries/oai2-to-oai3/test/resources/conversion/oai3/request-body-openapi.yaml diff --git a/libraries/oai2-to-oai3/test/resources/conversion/tiny-openapi.yaml b/libraries/oai2-to-oai3/test/resources/conversion/oai3/tiny-openapi.yaml similarity index 100% rename from libraries/oai2-to-oai3/test/resources/conversion/tiny-openapi.yaml rename to libraries/oai2-to-oai3/test/resources/conversion/oai3/tiny-openapi.yaml diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai3/xml-service.json b/libraries/oai2-to-oai3/test/resources/conversion/oai3/xml-service.json new file mode 100644 index 0000000..2891c82 --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai3/xml-service.json @@ -0,0 +1,1613 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost:3000/" + } + ], + "info": { + "version": "1.0.0", + "title": "AutoRest Swagger BAT XML Service", + "description": "Test Infrastructure for AutoRest Swagger BAT" + }, + "paths": { + "/xml/complex-type-ref-no-meta": { + "get": { + "operationId": "xml_getComplexTypeRefNoMeta", + "description": "Get a complex type that has a ref to a complex type with no XML node", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty list.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/RootWithRefAndNoMeta" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putComplexTypeRefNoMeta", + "description": "Puts a complex type that has a ref to a complex type with no XML node", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "model", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/RootWithRefAndNoMeta" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/complex-type-ref-with-meta": { + "get": { + "operationId": "xml_getComplexTypeRefWithMeta", + "description": "Get a complex type that has a ref to a complex type with XML node", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty list.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/RootWithRefAndMeta" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putComplexTypeRefWithMeta", + "description": "Puts a complex type that has a ref to a complex type with XML node", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "model", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/RootWithRefAndMeta" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/simple": { + "get": { + "operationId": "xml_getSimple", + "description": "Get a simple XML document", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The simple XML document", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Slideshow" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putSimple", + "description": "Put a simple XML document", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "slideshow", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Slideshow" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/wrapped-lists": { + "get": { + "operationId": "xml_getWrappedLists", + "description": "Get an XML document with multiple wrapped lists", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The XML document with multiple wrapped lists", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/AppleBarrel" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putWrappedLists", + "description": "Put an XML document with multiple wrapped lists", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success" + }, + "default": { + "description": "Unexpected error", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "requestBody": { + "x-ms-requestBody-name": "wrappedLists", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/AppleBarrel" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/headers": { + "get": { + "operationId": "xml_getHeaders", + "description": "Get strongly-typed response headers.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The response header.", + "headers": { + "Custom-Header": { + "description": "A custom response header.", + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/xml/empty-list": { + "get": { + "operationId": "xml_getEmptyList", + "description": "Get an empty list.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty list.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Slideshow" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putEmptyList", + "description": "Puts an empty list.", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "slideshow", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Slideshow" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/empty-wrapped-lists": { + "get": { + "operationId": "xml_getEmptyWrappedLists", + "description": "Gets some empty wrapped lists.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The empty lists.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/AppleBarrel" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putEmptyWrappedLists", + "description": "Puts some empty wrapped lists.", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "appleBarrel", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/AppleBarrel" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/root-list": { + "get": { + "operationId": "xml_getRootList", + "description": "Gets a list as the root element.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The root list.", + "content": { + "application/xml": { + "schema": { + "type": "array", + "xml": { + "name": "bananas" + }, + "items": { + "$ref": "#/components/schemas/Banana" + } + } + } + } + } + } + }, + "put": { + "operationId": "xml_putRootList", + "description": "Puts a list as the root element.", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "bananas", + "content": { + "application/xml": { + "schema": { + "type": "array", + "xml": { + "name": "bananas", + "wrapped": true + }, + "items": { + "$ref": "#/components/schemas/Banana" + } + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/root-list-single-item": { + "get": { + "operationId": "xml_getRootListSingleItem", + "description": "Gets a list with a single item.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The root list.", + "content": { + "application/xml": { + "schema": { + "type": "array", + "xml": { + "name": "bananas" + }, + "items": { + "$ref": "#/components/schemas/Banana" + } + } + } + } + } + } + }, + "put": { + "operationId": "xml_putRootListSingleItem", + "description": "Puts a list with a single item.", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "bananas", + "content": { + "application/xml": { + "schema": { + "type": "array", + "xml": { + "name": "bananas", + "wrapped": true + }, + "items": { + "$ref": "#/components/schemas/Banana" + } + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/empty-root-list": { + "get": { + "operationId": "xml_getEmptyRootList", + "description": "Gets an empty list as the root element.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The root list.", + "content": { + "application/xml": { + "schema": { + "type": "array", + "xml": { + "name": "bananas" + }, + "items": { + "$ref": "#/components/schemas/Banana" + } + } + } + } + } + } + }, + "put": { + "operationId": "xml_putEmptyRootList", + "description": "Puts an empty list as the root element.", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "bananas", + "content": { + "application/xml": { + "schema": { + "type": "array", + "xml": { + "name": "bananas", + "wrapped": true + }, + "items": { + "$ref": "#/components/schemas/Banana" + } + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/empty-child-element": { + "get": { + "operationId": "xml_getEmptyChildElement", + "description": "Gets an XML document with an empty child element.", + "tags": [ + "XML Operations" + ], + "responses": { + "200": { + "description": "The unknown banana.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Banana" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putEmptyChildElement", + "description": "Puts a value with an empty child element.", + "tags": [ + "XML Operations" + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "banana", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Banana" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/xml/?comp=list": { + "get": { + "operationId": "xml_listContainers", + "description": "Lists containers in a storage account.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "list" + ] + } + } + ], + "responses": { + "200": { + "description": "A list of containers.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/ListContainersResponse" + } + } + } + } + } + } + }, + "/xml/?comp=properties&restype=service": { + "get": { + "operationId": "xml_getServiceProperties", + "description": "Gets storage service properties.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "properties" + ] + } + }, + { + "name": "restype", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "service" + ] + } + } + ], + "responses": { + "200": { + "description": "The storage service properties.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/StorageServiceProperties" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putServiceProperties", + "description": "Puts storage service properties.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "properties" + ] + } + }, + { + "name": "restype", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "service" + ] + } + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "properties", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/StorageServiceProperties" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 2 + } + }, + "/xml/mycontainer?comp=acl&restype=container": { + "get": { + "operationId": "xml_getAcls", + "description": "Gets storage ACLs for a container.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "acl" + ] + } + }, + { + "name": "restype", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "container" + ] + } + } + ], + "responses": { + "200": { + "description": "The storage ACLs.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/SignedIdentifiers" + } + } + } + } + } + }, + "put": { + "operationId": "xml_putAcls", + "description": "Puts storage ACLs for a container.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "acl" + ] + } + }, + { + "name": "restype", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "container" + ] + } + } + ], + "responses": { + "201": { + "description": "Indicates success." + } + }, + "requestBody": { + "x-ms-requestBody-name": "properties", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/SignedIdentifiers" + } + } + }, + "required": true + }, + "x-ms-requestBody-index": 2 + } + }, + "/xml/mycontainer?comp=list&restype=container": { + "get": { + "operationId": "xml_listBlobs", + "description": "Lists blobs in a storage container.", + "tags": [ + "XML Operations" + ], + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "list" + ] + } + }, + { + "name": "restype", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "container" + ] + } + } + ], + "responses": { + "200": { + "description": "A list of containers.", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/ListBlobsResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Error": { + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + }, + "Slide": { + "type": "object", + "description": "A slide in a slideshow", + "properties": { + "type": { + "type": "string", + "xml": { + "attribute": true + } + }, + "title": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "type": "string", + "xml": { + "name": "item" + } + } + } + }, + "xml": { + "name": "slide" + } + }, + "Slideshow": { + "type": "object", + "description": "Data about a slideshow", + "xml": { + "name": "slideshow" + }, + "properties": { + "title": { + "type": "string", + "xml": { + "attribute": true + } + }, + "date": { + "type": "string", + "xml": { + "attribute": true + } + }, + "author": { + "type": "string", + "xml": { + "attribute": true + } + }, + "slides": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Slide" + } + } + } + }, + "AppleBarrel": { + "type": "object", + "description": "A barrel of apples.", + "properties": { + "GoodApples": { + "type": "array", + "items": { + "type": "string", + "xml": { + "name": "Apple" + } + }, + "xml": { + "wrapped": true + } + }, + "BadApples": { + "type": "array", + "items": { + "type": "string", + "xml": { + "name": "Apple" + } + }, + "xml": { + "wrapped": true + } + } + } + }, + "Banana": { + "type": "object", + "description": "A banana.", + "properties": { + "name": { + "type": "string", + "xml": { + "name": "name" + } + }, + "flavor": { + "type": "string", + "xml": { + "name": "flavor" + } + }, + "expiration": { + "description": "The time at which you should reconsider eating this banana", + "type": "string", + "format": "date-time", + "xml": { + "name": "expiration" + } + } + }, + "xml": { + "name": "banana" + } + }, + "Container": { + "type": "object", + "required": [ + "Name", + "Properties" + ], + "description": "An Azure Storage container", + "properties": { + "Name": { + "type": "string" + }, + "Properties": { + "$ref": "#/components/schemas/ContainerProperties" + }, + "Metadata": { + "$ref": "#/components/schemas/Metadata" + } + } + }, + "ContainerProperties": { + "type": "object", + "required": [ + "Last-Modified", + "Etag" + ], + "description": "Properties of a container", + "properties": { + "Last-Modified": { + "type": "string", + "format": "date-time-rfc1123" + }, + "Etag": { + "type": "string", + "format": "etag" + }, + "LeaseStatus": { + "$ref": "#/components/schemas/LeaseStatus" + }, + "LeaseState": { + "$ref": "#/components/schemas/LeaseState" + }, + "LeaseDuration": { + "$ref": "#/components/schemas/LeaseDuration" + }, + "PublicAccess": { + "$ref": "#/components/schemas/PublicAccessType" + } + } + }, + "ListContainersResponse": { + "xml": { + "name": "EnumerationResults" + }, + "description": "An enumeration of containers", + "type": "object", + "required": [ + "ServiceEndpoint", + "Prefix", + "MaxResults", + "NextMarker" + ], + "properties": { + "ServiceEndpoint": { + "type": "string", + "xml": { + "attribute": true + } + }, + "Prefix": { + "type": "string" + }, + "Marker": { + "type": "string" + }, + "MaxResults": { + "type": "integer" + }, + "Containers": { + "xml": { + "wrapped": true + }, + "type": "array", + "items": { + "$ref": "#/components/schemas/Container" + } + }, + "NextMarker": { + "type": "string" + } + } + }, + "CorsRule": { + "description": "CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain", + "type": "object", + "required": [ + "AllowedOrigins", + "AllowedMethods", + "AllowedHeaders", + "ExposedHeaders", + "MaxAgeInSeconds" + ], + "properties": { + "AllowedOrigins": { + "description": "The origin domains that are permitted to make a request against the storage service via CORS. The origin domain is the domain from which the request originates. Note that the origin must be an exact case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' to allow all origin domains to make requests via CORS.", + "type": "string" + }, + "AllowedMethods": { + "description": "The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated)", + "type": "string" + }, + "AllowedHeaders": { + "description": "the request headers that the origin domain may specify on the CORS request.", + "type": "string" + }, + "ExposedHeaders": { + "description": "The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer", + "type": "string" + }, + "MaxAgeInSeconds": { + "description": "The maximum amount time that a browser should cache the preflight OPTIONS request.", + "type": "integer", + "minimum": 0 + } + }, + "xml": { + "name": "CorsRule" + } + }, + "Blob": { + "description": "An Azure Storage blob", + "type": "object", + "required": [ + "Name", + "Deleted", + "Snapshot", + "Properties" + ], + "properties": { + "Name": { + "type": "string" + }, + "Deleted": { + "type": "boolean" + }, + "Snapshot": { + "type": "string" + }, + "Properties": { + "$ref": "#/components/schemas/BlobProperties" + }, + "Metadata": { + "$ref": "#/components/schemas/Metadata" + } + }, + "xml": { + "name": "Blob" + } + }, + "BlobProperties": { + "description": "Properties of a blob", + "type": "object", + "required": [ + "Etag", + "Last-Modified" + ], + "properties": { + "Last-Modified": { + "type": "string", + "format": "date-time-rfc1123" + }, + "Etag": { + "type": "string", + "format": "etag" + }, + "Content-Length": { + "type": "integer", + "format": "int64", + "description": "Size in bytes" + }, + "Content-Type": { + "type": "string" + }, + "Content-Encoding": { + "type": "string" + }, + "Content-Language": { + "type": "string" + }, + "Content-MD5": { + "type": "string" + }, + "Content-Disposition": { + "type": "string" + }, + "Cache-Control": { + "type": "string" + }, + "x-ms-blob-sequence-number": { + "x-ms-client-name": "blobSequenceNumber", + "type": "integer" + }, + "BlobType": { + "type": "string", + "enum": [ + "BlockBlob", + "PageBlob", + "AppendBlob" + ], + "x-ms-enum": { + "name": "BlobType", + "modelAsString": false + } + }, + "LeaseStatus": { + "$ref": "#/components/schemas/LeaseStatus" + }, + "LeaseState": { + "$ref": "#/components/schemas/LeaseState" + }, + "LeaseDuration": { + "$ref": "#/components/schemas/LeaseDuration" + }, + "CopyId": { + "type": "string" + }, + "CopyStatus": { + "$ref": "#/components/schemas/CopyStatus" + }, + "CopySource": { + "type": "string" + }, + "CopyProgress": { + "type": "string" + }, + "CopyCompletionTime": { + "type": "string", + "format": "date-time-rfc1123" + }, + "CopyStatusDescription": { + "type": "string" + }, + "ServerEncrypted": { + "type": "boolean" + }, + "IncrementalCopy": { + "type": "boolean" + }, + "DestinationSnapshot": { + "type": "string" + }, + "DeletedTime": { + "type": "string", + "format": "date-time-rfc1123" + }, + "RemainingRetentionDays": { + "type": "integer" + }, + "AccessTier": { + "$ref": "#/components/schemas/AccessTier" + }, + "AccessTierInferred": { + "type": "boolean" + }, + "ArchiveStatus": { + "$ref": "#/components/schemas/ArchiveStatus" + } + } + }, + "Logging": { + "description": "Azure Analytics Logging settings.", + "type": "object", + "required": [ + "Version", + "Delete", + "Read", + "Write", + "RetentionPolicy" + ], + "properties": { + "Version": { + "description": "The version of Storage Analytics to configure.", + "type": "string" + }, + "Delete": { + "description": "Indicates whether all delete requests should be logged.", + "type": "boolean" + }, + "Read": { + "description": "Indicates whether all read requests should be logged.", + "type": "boolean" + }, + "Write": { + "description": "Indicates whether all write requests should be logged.", + "type": "boolean" + }, + "RetentionPolicy": { + "$ref": "#/components/schemas/RetentionPolicy" + } + } + }, + "Metadata": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "Metrics": { + "description": "", + "required": [ + "Enabled" + ], + "properties": { + "Version": { + "description": "The version of Storage Analytics to configure.", + "type": "string" + }, + "Enabled": { + "description": "Indicates whether metrics are enabled for the Blob service.", + "type": "boolean" + }, + "IncludeAPIs": { + "description": "Indicates whether metrics should generate summary statistics for called API operations.", + "type": "boolean" + }, + "RetentionPolicy": { + "$ref": "#/components/schemas/RetentionPolicy" + } + } + }, + "ListBlobsResponse": { + "xml": { + "name": "EnumerationResults" + }, + "description": "An enumeration of blobs", + "type": "object", + "required": [ + "ServiceEndpoint", + "ContainerName", + "Prefix", + "Marker", + "MaxResults", + "Delimiter", + "Blobs", + "NextMarker" + ], + "properties": { + "ServiceEndpoint": { + "type": "string", + "xml": { + "attribute": true + } + }, + "ContainerName": { + "type": "string", + "xml": { + "attribute": true + } + }, + "Prefix": { + "type": "string" + }, + "Marker": { + "type": "string" + }, + "MaxResults": { + "type": "integer" + }, + "Delimiter": { + "type": "string" + }, + "Blobs": { + "$ref": "#/components/schemas/Blobs" + }, + "NextMarker": { + "type": "string" + } + } + }, + "Blobs": { + "type": "object", + "properties": { + "BlobPrefix": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BlobPrefix" + } + }, + "Blob": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Blob" + } + } + } + }, + "BlobPrefix": { + "type": "object", + "required": [ + "Name" + ], + "properties": { + "Name": { + "type": "string" + } + } + }, + "PublicAccessType": { + "type": "string", + "enum": [ + "container", + "blob" + ], + "x-ms-enum": { + "name": "PublicAccessType", + "modelAsString": true + } + }, + "CopyStatus": { + "type": "string", + "enum": [ + "pending", + "success", + "aborted", + "failed" + ], + "x-ms-enum": { + "name": "CopyStatusType", + "modelAsString": false + } + }, + "LeaseDuration": { + "type": "string", + "enum": [ + "infinite", + "fixed" + ], + "x-ms-enum": { + "name": "LeaseDurationType", + "modelAsString": false + } + }, + "LeaseState": { + "type": "string", + "enum": [ + "available", + "leased", + "expired", + "breaking", + "broken" + ], + "x-ms-enum": { + "name": "LeaseStateType", + "modelAsString": false + } + }, + "LeaseStatus": { + "type": "string", + "enum": [ + "locked", + "unlocked" + ], + "x-ms-enum": { + "name": "LeaseStatusType", + "modelAsString": false + } + }, + "AccessPolicy": { + "type": "object", + "required": [ + "Start", + "Expiry", + "Permission" + ], + "description": "An Access policy", + "properties": { + "Start": { + "description": "the date-time the policy is active", + "type": "string", + "format": "date-time" + }, + "Expiry": { + "description": "the date-time the policy expires", + "type": "string", + "format": "date-time" + }, + "Permission": { + "description": "the permissions for the acl policy", + "type": "string" + } + } + }, + "AccessTier": { + "type": "string", + "enum": [ + "P4", + "P6", + "P10", + "P20", + "P30", + "P40", + "P50", + "Hot", + "Cool", + "Archive" + ], + "x-ms-enum": { + "name": "AccessTier", + "modelAsString": true + } + }, + "ArchiveStatus": { + "type": "string", + "enum": [ + "rehydrate-pending-to-hot", + "rehydrate-pending-to-cool" + ], + "x-ms-enum": { + "name": "ArchiveStatus", + "modelAsString": true + } + }, + "RetentionPolicy": { + "description": "the retention policy", + "type": "object", + "required": [ + "Enabled" + ], + "properties": { + "Enabled": { + "description": "Indicates whether a retention policy is enabled for the storage service", + "type": "boolean" + }, + "Days": { + "description": "Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this value will be deleted", + "type": "integer", + "minimum": 1 + } + } + }, + "SignedIdentifier": { + "description": "signed identifier", + "type": "object", + "required": [ + "Id", + "AccessPolicy" + ], + "properties": { + "Id": { + "type": "string", + "description": "a unique id" + }, + "AccessPolicy": { + "description": "The access policy", + "$ref": "#/components/schemas/AccessPolicy" + } + }, + "xml": { + "name": "SignedIdentifier" + } + }, + "SignedIdentifiers": { + "description": "a collection of signed identifiers", + "type": "array", + "items": { + "$ref": "#/components/schemas/SignedIdentifier" + }, + "xml": { + "wrapped": true, + "name": "SignedIdentifiers" + } + }, + "StorageServiceProperties": { + "description": "Storage Service Properties.", + "type": "object", + "properties": { + "Logging": { + "description": "Azure Analytics Logging settings", + "$ref": "#/components/schemas/Logging" + }, + "HourMetrics": { + "description": "A summary of request statistics grouped by API in hourly aggregates for blobs", + "$ref": "#/components/schemas/Metrics" + }, + "MinuteMetrics": { + "description": "a summary of request statistics grouped by API in minute aggregates for blobs", + "$ref": "#/components/schemas/Metrics" + }, + "Cors": { + "description": "The set of CORS rules.", + "type": "array", + "items": { + "$ref": "#/components/schemas/CorsRule" + }, + "xml": { + "wrapped": true + } + }, + "DefaultServiceVersion": { + "description": "The default version to use for requests to the Blob service if an incoming request's version is not specified. Possible values include version 2008-10-27 and all more recent versions", + "type": "string" + }, + "DeleteRetentionPolicy": { + "description": "The Delete Retention Policy for the service", + "$ref": "#/components/schemas/RetentionPolicy" + } + } + }, + "ComplexTypeNoMeta": { + "description": "I am a complex type with no XML node", + "type": "object", + "properties": { + "ID": { + "description": "The id of the res", + "type": "string" + } + } + }, + "ComplexTypeWithMeta": { + "description": "I am a complex type with XML node", + "type": "object", + "properties": { + "ID": { + "description": "The id of the res", + "type": "string" + } + }, + "xml": { + "name": "XMLComplexTypeWithMeta" + } + }, + "RootWithRefAndNoMeta": { + "description": "I am root, and I ref a model with no meta", + "type": "object", + "properties": { + "RefToModel": { + "description": "XML will use RefToModel", + "$ref": "#/components/schemas/ComplexTypeNoMeta" + }, + "Something": { + "description": "Something else (just to avoid flattening)", + "type": "string" + } + } + }, + "RootWithRefAndMeta": { + "description": "I am root, and I ref a model WITH meta", + "type": "object", + "properties": { + "RefToModel": { + "description": "XML will use XMLComplexTypeWithMeta", + "$ref": "#/components/schemas/ComplexTypeWithMeta" + }, + "Something": { + "description": "Something else (just to avoid flattening)", + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/resources/conversion/oai3/xms-error-responses.json b/libraries/oai2-to-oai3/test/resources/conversion/oai3/xms-error-responses.json new file mode 100644 index 0000000..4cbfb2d --- /dev/null +++ b/libraries/oai2-to-oai3/test/resources/conversion/oai3/xms-error-responses.json @@ -0,0 +1,262 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost/" + } + ], + "info": { + "version": "0.0.0", + "title": "XMS Error Response Extensions", + "description": "XMS Error Response Extensions" + }, + "paths": { + "/errorStatusCodes/Pets/{petId}/GetPet": { + "get": { + "operationId": "Pet_GetPetById", + "description": "Gets pets by id.", + "parameters": [ + { + "name": "petId", + "in": "path", + "required": true, + "description": "pet id", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "202": { + "description": "something something dark side" + }, + "400": { + "description": "Bad request", + "x-ms-error-response": true, + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found", + "x-ms-error-response": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundErrorBase" + } + } + } + }, + "501": { + "description": "Some unexpected error", + "x-ms-error-response": true, + "content": { + "application/json": { + "schema": { + "type": "integer" + } + } + } + }, + "default": { + "description": "default stuff" + } + } + } + }, + "/errorStatusCodes/Pets/doSomething/{whatAction}": { + "post": { + "operationId": "Pet_DoSomething", + "description": "Asks pet to do something", + "parameters": [ + { + "name": "whatAction", + "in": "path", + "required": true, + "description": "what action the pet should do", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "action performed", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetAction" + } + } + } + }, + "500": { + "description": "something bad happened", + "x-ms-error-response": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetActionError" + } + } + } + }, + "default": { + "description": "default stuff", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PetActionError" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Pet": { + "allOf": [ + { + "$ref": "#/components/schemas/Animal" + } + ], + "properties": { + "name": { + "type": "string", + "readOnly": true, + "description": "Gets the Pet by id." + } + } + }, + "NotFoundErrorBase": { + "properties": { + "reason": { + "type": "string" + }, + "whatNotFound": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/BaseError" + } + ], + "required": [ + "whatNotFound" + ], + "discriminator": { + "propertyName": "whatNotFound" + } + }, + "BaseError": { + "properties": { + "someBaseProp": { + "type": "string" + } + } + }, + "LinkNotFound": { + "properties": { + "whatSubAddress": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/NotFoundErrorBase" + } + ], + "x-ms-discriminator-value": "InvalidResourceLink" + }, + "AnimalNotFound": { + "properties": { + "name": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/NotFoundErrorBase" + } + ] + }, + "Animal": { + "properties": { + "aniType": { + "type": "string" + } + } + }, + "PetAction": { + "properties": { + "actionResponse": { + "type": "string", + "description": "action feedback" + } + } + }, + "PetActionError": { + "properties": { + "errorType": { + "type": "string" + }, + "errorMessage": { + "type": "string", + "description": "the error message" + } + }, + "required": [ + "errorType" + ], + "discriminator": { + "propertyName": "errorType" + } + }, + "PetSadError": { + "allOf": [ + { + "$ref": "#/components/schemas/PetActionError" + } + ], + "properties": { + "reason": { + "type": "string", + "description": "why is the pet sad" + } + } + }, + "PetHungryOrThirstyError": { + "allOf": [ + { + "$ref": "#/components/schemas/PetSadError" + } + ], + "properties": { + "hungryOrThirsty": { + "type": "string", + "description": "is the pet hungry or thirsty or both" + } + } + } + } + } +} \ No newline at end of file diff --git a/libraries/oai2-to-oai3/test/test-conversion.ts b/libraries/oai2-to-oai3/test/test-conversion.ts index 3d42718..396bbb1 100644 --- a/libraries/oai2-to-oai3/test/test-conversion.ts +++ b/libraries/oai2-to-oai3/test/test-conversion.ts @@ -15,8 +15,8 @@ import { Oai2ToOai3 } from '../main'; const swaggerUri = 'mem://swagger.yaml'; const oai3Uri = 'mem://oai3.yaml'; - const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/swagger.yaml`); - const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/openapi.yaml`); + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/swagger.yaml`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/openapi.yaml`); const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); const mfs = new datastore.MemoryFileSystem(map); @@ -49,8 +49,8 @@ import { Oai2ToOai3 } from '../main'; const swaggerUri = 'mem://tiny-swagger.yaml'; const oai3Uri = 'mem://tiny-oai3.yaml'; - const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/tiny-swagger.yaml`); - const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/tiny-openapi.yaml`); + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/tiny-swagger.yaml`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/tiny-openapi.yaml`); const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); const mfs = new datastore.MemoryFileSystem(map); @@ -83,8 +83,8 @@ import { Oai2ToOai3 } from '../main'; const swaggerUri = 'mem://ApiManagementClient-swagger.json'; const oai3Uri = 'mem://ApiManagementClient-oai3.json'; - const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/ApiManagementClient-swagger.json`); - const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/ApiManagementClient-openapi.json`); + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/ApiManagementClient-swagger.json`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/ApiManagementClient-openapi.json`); const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); const mfs = new datastore.MemoryFileSystem(map); @@ -117,8 +117,8 @@ import { Oai2ToOai3 } from '../main'; const swaggerUri = 'mem://request-body-swagger.yaml'; const oai3Uri = 'mem://request-body-openapi.yaml'; - const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/request-body-swagger.yaml`); - const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/request-body-openapi.yaml`); + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/request-body-swagger.yaml`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/request-body-openapi.yaml`); const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); const mfs = new datastore.MemoryFileSystem(map); @@ -147,10 +147,134 @@ import { Oai2ToOai3 } from '../main'; } } + @test async "headers"() { + const swaggerUri = 'mem://header2.json'; + const oai3Uri = 'mem://header3.json'; + + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/header.json`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/header.json`); + + const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); + const mfs = new datastore.MemoryFileSystem(map); + + const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: null } }; + const ds = new datastore.DataStore(cts.token); + const scope = ds.GetReadThroughScope(mfs); + const swaggerDataHandle = await scope.Read(swaggerUri); + const originalDataHandle = await scope.Read(oai3Uri) + + assert(swaggerDataHandle != null); + assert(originalDataHandle != null); + + if (swaggerDataHandle && originalDataHandle) { + const swag = swaggerDataHandle.ReadObject(); + const original = originalDataHandle.ReadObject(); + const convert = new Oai2ToOai3(swaggerUri, swag); + + // run the conversion + convert.convert(); + + assert.deepEqual(convert.generated, original, "Should be the same"); + } + } + + @test async "additionalProperties"() { + const swaggerUri = 'mem://additionalProperties2.json'; + const oai3Uri = 'mem://additionalProperties3.json'; + + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/additionalProperties.json`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/additionalProperties.json`); + + const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); + const mfs = new datastore.MemoryFileSystem(map); + + const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: null } }; + const ds = new datastore.DataStore(cts.token); + const scope = ds.GetReadThroughScope(mfs); + const swaggerDataHandle = await scope.Read(swaggerUri); + const originalDataHandle = await scope.Read(oai3Uri) + + assert(swaggerDataHandle != null); + assert(originalDataHandle != null); + + if (swaggerDataHandle && originalDataHandle) { + const swag = swaggerDataHandle.ReadObject(); + const original = originalDataHandle.ReadObject(); + const convert = new Oai2ToOai3(swaggerUri, swag); + + // run the conversion + convert.convert(); + + assert.deepEqual(convert.generated, original, "Should be the same"); + } + } + + @test async "xml-service"() { + const swaggerUri = 'mem://xml-service2.json'; + const oai3Uri = 'mem://xml-service3.json'; + + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/xml-service.json`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/xml-service.json`); + + const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); + const mfs = new datastore.MemoryFileSystem(map); + + const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: null } }; + const ds = new datastore.DataStore(cts.token); + const scope = ds.GetReadThroughScope(mfs); + const swaggerDataHandle = await scope.Read(swaggerUri); + const originalDataHandle = await scope.Read(oai3Uri) + + assert(swaggerDataHandle != null); + assert(originalDataHandle != null); + + if (swaggerDataHandle && originalDataHandle) { + const swag = swaggerDataHandle.ReadObject(); + const original = originalDataHandle.ReadObject(); + const convert = new Oai2ToOai3(swaggerUri, swag); + + // run the conversion + convert.convert(); + + assert.deepEqual(convert.generated, original, "Should be the same"); + } + } + + @test async "xms-error-responses"() { + const swaggerUri = 'mem://xms-error-responses2.json'; + const oai3Uri = 'mem://xms-error-responses3.json'; + + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/xms-error-responses.json`); + const oai3 = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai3/xms-error-responses.json`); + + const map = new Map([[swaggerUri, swagger], [oai3Uri, oai3]]); + const mfs = new datastore.MemoryFileSystem(map); + + const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: null } }; + const ds = new datastore.DataStore(cts.token); + const scope = ds.GetReadThroughScope(mfs); + const swaggerDataHandle = await scope.Read(swaggerUri); + const originalDataHandle = await scope.Read(oai3Uri) + + assert(swaggerDataHandle != null); + assert(originalDataHandle != null); + + if (swaggerDataHandle && originalDataHandle) { + const swag = swaggerDataHandle.ReadObject(); + const original = originalDataHandle.ReadObject(); + const convert = new Oai2ToOai3(swaggerUri, swag); + + // run the conversion + convert.convert(); + + assert.deepEqual(convert.generated, original, "Should be the same"); + } + } + /* @test */ async "test conversion with sourcemap"() { const absoluteUri = 'swagger.yaml'; - const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/swagger.yaml`); + const swagger = await aio.readFile(`${__dirname}/../../test/resources/conversion/oai2/swagger.yaml`); const map = new Map([[absoluteUri, swagger]]); const mfs = new datastore.MemoryFileSystem(map);