Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenAPI3] Remove statusCode from shared routes responses #2555

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/openapi3",
"comment": "Fix issue where openAPI3 for shared routes incorrectly output a statusCode field.",
"type": "none"
}
],
"packageName": "@typespec/openapi3"
}
1 change: 0 additions & 1 deletion packages/openapi3/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ function createOAPIEmitter(program: Program, options: ResolvedOpenAPI3EmitterOpt
const openApiResponse: any = {
description: undefined,
content: {},
statusCode: statusCode,
};
const schemaMap = new Map<string, any[]>();
for (const response of responses) {
Expand Down
14 changes: 12 additions & 2 deletions packages/openapi3/test/shared-routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ describe("openapi3: shared routes", () => {
results.paths["/sharedroutes/resources"].post.operationId,
"List_ResourceGroup_List_Subscription"
);
deepStrictEqual(
results.paths["/sharedroutes/resources"].post.responses["200"].statusCode,
undefined
);
const params = results.paths["/sharedroutes/resources"].post.parameters as {
name: string;
required: boolean;
Expand Down Expand Up @@ -112,6 +116,10 @@ describe("openapi3: shared routes", () => {
results.paths["/sharedroutes/resources"].post.operationId,
"listByResourceGroup_listBySubscription"
);
deepStrictEqual(
results.paths["/sharedroutes/resources"].post.responses["200"].statusCode,
undefined
);
const params = results.paths["/sharedroutes/resources"].post.parameters as {
name: string;
required: boolean;
Expand Down Expand Up @@ -153,6 +161,10 @@ describe("openapi3: shared routes", () => {
results.paths["/sharedroutes/resources"].post.operationId,
"listByResourceGroup_listBySubscription"
);
deepStrictEqual(
results.paths["/sharedroutes/resources"].post.responses["200"].statusCode,
undefined
);
const params = results.paths["/sharedroutes/resources"].post.parameters as {
name: string;
required: boolean;
Expand Down Expand Up @@ -221,7 +233,6 @@ describe("openapi3: shared routes", () => {
},
},
},
statusCode: "200",
description: "The request has succeeded.",
},
});
Expand Down Expand Up @@ -389,7 +400,6 @@ describe("openapi3: shared routes", () => {
},
},
},
statusCode: "200",
description: "The request has succeeded.",
},
});
Expand Down