From cc754dbb1cce63cd06f4e3b8ba2b4439d4927089 Mon Sep 17 00:00:00 2001 From: Hunter Petersen Date: Thu, 30 Mar 2023 22:44:38 -0700 Subject: [PATCH] Ignore non-method fields in Path Object Item (#4934) * path object summary/desc fix * fix(openapi): ignore non method objects under paths --------- Co-authored-by: Arda TANRIKULU --- .changeset/happy-melons-vanish.md | 5 +++++ .../openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts | 2 +- packages/loaders/openapi/tests/fixtures/basket.json | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/happy-melons-vanish.md diff --git a/.changeset/happy-melons-vanish.md b/.changeset/happy-melons-vanish.md new file mode 100644 index 0000000000000..5946161ad6fdb --- /dev/null +++ b/.changeset/happy-melons-vanish.md @@ -0,0 +1,5 @@ +--- +'@omnigraph/openapi': patch +--- + +Ignore non object path fields diff --git a/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts b/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts index 5d1f8faeaadd8..a027088f58b0b 100644 --- a/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts +++ b/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts @@ -122,7 +122,7 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions( const pathObj = oasOrSwagger.paths[relativePath]; const pathParameters = pathObj.parameters; for (const method in pathObj) { - if (method === 'parameters' || method === 'servers') { + if (method === 'parameters' || method === 'summary' || method === 'description' || method === 'servers') { continue; } const methodObj = pathObj[method as OpenAPIV2.HttpMethods] as diff --git a/packages/loaders/openapi/tests/fixtures/basket.json b/packages/loaders/openapi/tests/fixtures/basket.json index 016d88c2501f3..10f860f2a5b3b 100644 --- a/packages/loaders/openapi/tests/fixtures/basket.json +++ b/packages/loaders/openapi/tests/fixtures/basket.json @@ -6,6 +6,13 @@ }, "paths": { "/basket": { + "summary": "Get basket", + "description": "Get basket", + "servers": [ + { + "url": "https://api.example.com" + } + ], "post": { "requestBody": { "content": {