Skip to content

Commit bdb071a

Browse files
committed
fix(openapi-generator): remove duplicate descriptions in endpoint parameters
DX-427
1 parent 2365e36 commit bdb071a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/openapi-generator/src/openapi.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ function routeToOpenAPI(route: Route): [string, string, OpenAPIV3.OperationObjec
200200
// Array types not allowed here
201201
const schema = schemaToOpenAPI(p.schema);
202202

203+
if (schema && 'description' in schema) {
204+
delete schema.description;
205+
}
206+
203207
return {
204208
name: p.name,
205209
...(p.schema?.comment?.description !== undefined

packages/openapi-generator/test/openapi.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ testCase('simple route', SIMPLE, {
161161
description: 'foo param',
162162
required: true,
163163
schema: {
164-
description: 'foo param',
165164
type: 'string',
166165
},
167166
},
@@ -928,7 +927,6 @@ testCase('schema parameter with title tag', TITLE_TAG, {
928927
description: 'bar param',
929928
required: true,
930929
schema: {
931-
description: 'bar param',
932930
title: 'this is a bar parameter',
933931
type: 'string',
934932
},
@@ -1349,6 +1347,10 @@ export const route = h.httpRoute({
13491347
path: '/foo',
13501348
method: 'GET',
13511349
request: h.httpRequest({
1350+
query: {
1351+
/** bar param */
1352+
bar: t.string,
1353+
},
13521354
body: {
13531355
/** foo description */
13541356
foo: t.string,
@@ -1380,7 +1382,17 @@ testCase('route with type descriptions', ROUTE_WITH_TYPE_DESCRIPTIONS, {
13801382
summary: 'A simple route with type descriptions',
13811383
operationId: 'api.v1.test',
13821384
tags: ['Test Routes'],
1383-
parameters: [],
1385+
parameters: [
1386+
{
1387+
description: 'bar param',
1388+
in: 'query',
1389+
name: 'bar',
1390+
required: true,
1391+
schema: {
1392+
type: 'string'
1393+
}
1394+
}
1395+
],
13841396
requestBody: {
13851397
content: {
13861398
'application/json': {

0 commit comments

Comments
 (0)