Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pshao25 committed Apr 19, 2024
1 parent d2e677e commit ca89bb9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/extensions/openapi-to-typespec/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const ApiVersion = "ApiVersion";
export const ApiVersion = "ApiVersion";
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TypespecProgram, EndpointParameter, Auth } from "../interfaces";
import { getOptions } from "../options";
import { generateDocs } from "../utils/docs";
import { getNamespaceStatement } from "../utils/namespace";
import { ApiVersion } from "../constants";

const VALID_VERSIONS = ["v3", "v4", "v5"];

Expand Down Expand Up @@ -53,7 +54,7 @@ export function generateServiceInformation(program: TypespecProgram) {
for (const param of allParams ?? []) {
const doc = generateDocs(param);
doc && definitions.push(doc);
definitions.push(`${param.name}: ${param.name.startsWith("ApiVersion") ? "Versions" : "string"} `);
definitions.push(`${param.name}: ${param.name.startsWith(ApiVersion) ? "Versions" : "string"} `);
}
}
hasParameters && definitions.push("}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function getCustomizations(
if (bodyParam) {
if (bodyParam.language.default.name !== templateName && isFullCompatible) {
augmentedDecorators.push(
`@@encodedName(${tspOperationGroupName}.\`${operationName}\`::parameters.${templateName}, "application/json", "${bodyParam.language.default.name}");`,
`@@encodedName(${tspOperationGroupName}.\`${operationName}\`::parameters.${templateName}, "json", "${bodyParam.language.default.name}");`,
);
augmentedDecorators.push(
`@@extension(${tspOperationGroupName}.\`${operationName}\`::parameters.${templateName}, "x-ms-client-name", "${bodyParam.language.default.name}");`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
OAuth2SecurityScheme,
ParameterLocation,
SecurityScheme,
codeModelSchema,
} from "@autorest/codemodel";
import { getArmCommonTypeVersion } from "../autorest-session";
import { AadOauth2AuthFlow, ApiKeyAuthentication, Auth, EndpointParameter, ServiceInformation } from "../interfaces";
import { getOptions } from "../options";
import { getFirstEndpoint } from "../utils/get-endpoint";
import { isConstantSchema } from "../utils/schemas";
import { ApiVersion } from "../constants";

export function transformServiceInformation(model: CodeModel): ServiceInformation {
const { isArm } = getOptions();
Expand Down

0 comments on commit ca89bb9

Please sign in to comment.