зеркало из https://github.com/Azure/autorest.git
Oai2 oai3 parameter extensions flexible (#4357)
This commit is contained in:
Родитель
74164f01b5
Коммит
511bc2ed08
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@azure-tools/oai2-to-oai3",
|
||||
"comment": "Copy all extensions on parameters",
|
||||
"type": "minor"
|
||||
}
|
||||
],
|
||||
"packageName": "@azure-tools/oai2-to-oai3",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -11,7 +11,14 @@ import {
|
|||
createMappingTree,
|
||||
} from "@azure-tools/datastore";
|
||||
import { JsonPointer, getFromJsonPointer, appendJsonPointer } from "@azure-tools/json";
|
||||
import oai3, { EncodingStyle, HttpOperation, JsonType, PathItem, SecurityType } from "@azure-tools/openapi";
|
||||
import oai3, {
|
||||
EncodingStyle,
|
||||
HttpOperation,
|
||||
includeXDashKeys,
|
||||
JsonType,
|
||||
PathItem,
|
||||
SecurityType,
|
||||
} from "@azure-tools/openapi";
|
||||
import { resolveOperationConsumes, resolveOperationProduces } from "./content-type-utils";
|
||||
import {
|
||||
OpenAPI2Document,
|
||||
|
@ -294,22 +301,7 @@ export class Oai2ToOai3 {
|
|||
if ("$ref" in parameterValue) {
|
||||
parameterTarget.__set__("$ref", { value: await this.convertReferenceToOai3(parameterValue.$ref), sourcePointer });
|
||||
} else {
|
||||
const parameterUnchangedProperties = [
|
||||
"name",
|
||||
"in",
|
||||
"description",
|
||||
"allowEmptyValue",
|
||||
"required",
|
||||
"x-ms-parameter-location",
|
||||
"x-ms-api-version",
|
||||
"x-comment",
|
||||
"x-ms-parameter-grouping",
|
||||
"x-ms-client-name",
|
||||
"x-ms-client-default",
|
||||
"x-ms-client-flatten",
|
||||
"x-ms-client-request-id",
|
||||
"x-ms-header-collection-prefix",
|
||||
];
|
||||
const parameterUnchangedProperties = ["name", "in", "description", "allowEmptyValue", "required"];
|
||||
|
||||
for (const key of parameterUnchangedProperties) {
|
||||
if (parameterValue[key] !== undefined) {
|
||||
|
@ -328,6 +320,17 @@ export class Oai2ToOai3 {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List of extension properties that shouldn't just be passed through.
|
||||
*/
|
||||
const extensionPropertiesCustom = new Set(["x-ms-skip-url-encoding", "x-ms-original", "x-ms-enum"]);
|
||||
|
||||
for (const key of includeXDashKeys(parameterValue)) {
|
||||
if (parameterValue[key] !== undefined && !extensionPropertiesCustom.has(key)) {
|
||||
parameterTarget.__set__(key, { value: parameterValue[key], sourcePointer });
|
||||
}
|
||||
}
|
||||
|
||||
// Collection Format
|
||||
if (parameterValue.type === "array") {
|
||||
parameterValue.collectionFormat = parameterValue.collectionFormat || "csv";
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
"in": "path",
|
||||
"description": "Shared endpoint param.",
|
||||
"required": true,
|
||||
"x-ms-parameter-location": "client",
|
||||
"x-ms-skip-url-encoding": true,
|
||||
"x-ms-parameter-location": "client",
|
||||
"schema": {
|
||||
"default": "https://api.cognitive.microsoft.com",
|
||||
"type": "string"
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/components/parameters/GlobalEndpoint/in => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/description => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/required => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/x-ms-parameter-location => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/x-ms-skip-url-encoding => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/x-ms-parameter-location => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/schema => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/schema/default => /parameters/GlobalEndpoint
|
||||
/components/parameters/GlobalEndpoint/schema/type => /parameters/GlobalEndpoint
|
Загрузка…
Ссылка в новой задаче