update converter: extensions not being copied are now copied.
This commit is contained in:
Родитель
600da94c77
Коммит
71a7581732
|
@ -13,7 +13,7 @@
|
|||
"dist/test",
|
||||
"--timeout=2000000"
|
||||
],
|
||||
"cwd": "${workspaceRoot}/libraries/deduplication",
|
||||
"cwd": "${workspaceRoot}/libraries/oai2-to-oai3",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
]
|
||||
|
|
|
@ -1042,7 +1042,42 @@ 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) {
|
||||
|
@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<string, string>([[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<string, string>([[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<string, string>([[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<string, string>([[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<string, string>([[swaggerUri, swagger], [oai3Uri, oai3]]);
|
||||
const mfs = new datastore.MemoryFileSystem(map);
|
||||
|
||||
const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: <any>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<string, string>([[swaggerUri, swagger], [oai3Uri, oai3]]);
|
||||
const mfs = new datastore.MemoryFileSystem(map);
|
||||
|
||||
const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: <any>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<string, string>([[swaggerUri, swagger], [oai3Uri, oai3]]);
|
||||
const mfs = new datastore.MemoryFileSystem(map);
|
||||
|
||||
const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: <any>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<string, string>([[swaggerUri, swagger], [oai3Uri, oai3]]);
|
||||
const mfs = new datastore.MemoryFileSystem(map);
|
||||
|
||||
const cts: datastore.CancellationTokenSource = { cancel() { }, dispose() { }, token: { isCancellationRequested: false, onCancellationRequested: <any>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<string, string>([[absoluteUri, swagger]]);
|
||||
const mfs = new datastore.MemoryFileSystem(map);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче