Skip to content

Commit 8a41f9c

Browse files
wtrockiAlan-Cha
authored andcommitted
fix: disable unuseful comments
Signed-off-by: Wojciech Trocki <[email protected]>
1 parent 808f18b commit 8a41f9c

File tree

7 files changed

+27
-55
lines changed

7 files changed

+27
-55
lines changed

packages/openapi-to-graphql/lib/preprocessor.js

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/preprocessor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/schema_builder.js

Lines changed: 4 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/schema_builder.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/src/preprocessor.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ export function preprocessOas(
9090
description = endpoint.summary
9191
}
9292

93-
if (typeof description !== 'string') {
94-
description = 'No description available.'
95-
}
96-
97-
if (data.options.equivalentToMessages) {
93+
if (data.options.equivalentToMessages && description) {
9894
description += `\n\nEquivalent to ${operationString}`
9995
}
10096

packages/openapi-to-graphql/src/schema_builder.ts

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ function createOrReuseOt({
186186
if (def.ot && typeof def.ot !== 'undefined') {
187187
translationLog(
188188
`Reuse object type '${def.otName}'` +
189-
(typeof operation === 'object'
190-
? ` (for operation '${operation.operationId}')`
191-
: '')
189+
(typeof operation === 'object'
190+
? ` (for operation '${operation.operationId}')`
191+
: '')
192192
)
193193
return def.ot as (
194194
| GraphQLObjectType
@@ -201,9 +201,9 @@ function createOrReuseOt({
201201
if (def.iot && typeof def.iot !== 'undefined') {
202202
translationLog(
203203
`Reuse input object type '${def.iotName}'` +
204-
(typeof operation === 'object'
205-
? ` (for operation '${operation.operationId}')`
206-
: '')
204+
(typeof operation === 'object'
205+
? ` (for operation '${operation.operationId}')`
206+
: '')
207207
)
208208
return def.iot as GraphQLInputObjectType
209209
}
@@ -213,10 +213,7 @@ function createOrReuseOt({
213213

214214
const schema = def.schema
215215

216-
const description =
217-
typeof schema.description !== 'undefined'
218-
? schema.description
219-
: 'No description available.'
216+
const description = schema.description
220217

221218
/**
222219
* If the schema does not contain any properties, then OpenAPI-to-GraphQL
@@ -248,9 +245,9 @@ function createOrReuseOt({
248245
if (!isInputObjectType) {
249246
translationLog(
250247
`Create object type '${def.otName}'` +
251-
(typeof operation === 'object'
252-
? ` (for operation '${operation.operationId}')`
253-
: '')
248+
(typeof operation === 'object'
249+
? ` (for operation '${operation.operationId}')`
250+
: '')
254251
)
255252

256253
def.ot = new GraphQLObjectType({
@@ -274,9 +271,9 @@ function createOrReuseOt({
274271
} else {
275272
translationLog(
276273
`Create input object type '${def.iotName}'` +
277-
(typeof operation === 'object'
278-
? ` (for operation '${operation.operationId}')`
279-
: '')
274+
(typeof operation === 'object'
275+
? ` (for operation '${operation.operationId}')`
276+
: '')
280277
)
281278

282279
def.iot = new GraphQLInputObjectType({
@@ -477,10 +474,8 @@ function createFields({
477474
? new GraphQLNonNull(objectType)
478475
: (objectType as GraphQLOutputType),
479476

480-
description:
481-
typeof schema.description === 'undefined'
482-
? 'No description available.'
483-
: schema.description
477+
description: schema.description
478+
484479
}
485480
}
486481
}
@@ -568,12 +563,8 @@ function createFields({
568563
const resObjectType = linkedOp.responseDefinition.ot
569564

570565
let description = link.description
571-
572-
if (typeof description !== 'string') {
573-
description = 'No description available.'
574-
}
575-
576-
if (data.options.equivalentToMessages) {
566+
567+
if (data.options.equivalentToMessages && description) {
577568
description += `\n\nEquivalent to ${linkedOp.operationString}`
578569
}
579570

@@ -1041,10 +1032,7 @@ export function getArgs({
10411032
}
10421033
args[saneName] = {
10431034
type: reqRequired ? new GraphQLNonNull(reqObjectType) : reqObjectType,
1044-
description:
1045-
typeof def.schema.description === 'undefined'
1046-
? 'No description available.'
1047-
: def.schema.description
1035+
description: def.schema.description
10481036
}
10491037
}
10501038

packages/openapi-to-graphql/test/example_api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test('Get descriptions', () => {
6262
description: 'The color of the car.'
6363
},
6464
{
65-
description: 'No description available.'
65+
description: null
6666
},
6767
{
6868
description: 'The model of the car.'

0 commit comments

Comments
 (0)