diff --git a/common/changes/@typespec/openapi3/openapi3-statusCodeShared_2023-10-10-20-29.json b/common/changes/@typespec/openapi3/openapi3-statusCodeShared_2023-10-10-20-29.json new file mode 100644 index 0000000000..605ee4674f --- /dev/null +++ b/common/changes/@typespec/openapi3/openapi3-statusCodeShared_2023-10-10-20-29.json @@ -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" +} \ No newline at end of file diff --git a/packages/openapi3/src/openapi.ts b/packages/openapi3/src/openapi.ts index 465a878478..46a965378b 100644 --- a/packages/openapi3/src/openapi.ts +++ b/packages/openapi3/src/openapi.ts @@ -847,7 +847,6 @@ function createOAPIEmitter(program: Program, options: ResolvedOpenAPI3EmitterOpt const openApiResponse: any = { description: undefined, content: {}, - statusCode: statusCode, }; const schemaMap = new Map(); for (const response of responses) { diff --git a/packages/openapi3/test/shared-routes.test.ts b/packages/openapi3/test/shared-routes.test.ts index aa5b244928..9b70e7f1c6 100644 --- a/packages/openapi3/test/shared-routes.test.ts +++ b/packages/openapi3/test/shared-routes.test.ts @@ -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; @@ -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; @@ -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; @@ -221,7 +233,6 @@ describe("openapi3: shared routes", () => { }, }, }, - statusCode: "200", description: "The request has succeeded.", }, }); @@ -389,7 +400,6 @@ describe("openapi3: shared routes", () => { }, }, }, - statusCode: "200", description: "The request has succeeded.", }, });