Skip to content

Commit 3027287

Browse files
committed
Do not throw error for anyOf, oneOf, and not
Related to IBM#197 and IBM#248 Signed-off-by: Alan Cha <[email protected]>
1 parent 8a41f9c commit 3027287

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

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

Lines changed: 18 additions & 3 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/utils.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export declare const mitigations: {
1414
UNSUPPORTED_HTTP_SECURITY_SCHEME: string;
1515
NON_APPLICATION_JSON_SCHEMA: string;
1616
OBJECT_MISSING_PROPERTIES: string;
17+
UNSUPPORTED_JSON_SCHEMA_KEYWORD: string;
1718
UNRESOLVABLE_LINK: string;
1819
AMBIGUOUS_LINK: string;
1920
LINK_NAME_COLLISION: string;

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

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

packages/openapi-to-graphql/lib/utils.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: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -537,23 +537,32 @@ export function createDataDef(
537537
if ('allOf' in schema) {
538538
addAllOfToDataDef(def, schema, isInputObjectType, data, oas)
539539
} else if ('anyOf' in schema) {
540-
throw new Error(
541-
`OpenAPI-to-GraphQL currently cannot handle 'anyOf' keyword in '${JSON.stringify(
540+
handleWarning({
541+
typeKey: 'UNSUPPORTED_JSON_SCHEMA_KEYWORD',
542+
message: `OpenAPI-to-GraphQL currently cannot handle 'anyOf' keyword in '${JSON.stringify(
542543
schema
543-
)}'`
544-
)
544+
)}'`,
545+
data,
546+
log: preprocessingLog
547+
})
545548
} else if ('oneOf' in schema) {
546-
throw new Error(
547-
`OpenAPI-to-GraphQL currently cannot handle 'oneOf' keyword in '${JSON.stringify(
549+
handleWarning({
550+
typeKey: 'UNSUPPORTED_JSON_SCHEMA_KEYWORD',
551+
message: `OpenAPI-to-GraphQL currently cannot handle 'oneOf' keyword in '${JSON.stringify(
548552
schema
549-
)}'`
550-
)
553+
)}'`,
554+
data,
555+
log: preprocessingLog
556+
})
551557
} else if ('not' in schema) {
552-
throw new Error(
553-
`OpenAPI-to-GraphQL currently cannot handle 'not' keyword in '${JSON.stringify(
558+
handleWarning({
559+
typeKey: 'UNSUPPORTED_JSON_SCHEMA_KEYWORD',
560+
message: `OpenAPI-to-GraphQL currently cannot handle 'not' keyword in '${JSON.stringify(
554561
schema
555-
)}'`
556-
)
562+
)}'`,
563+
data,
564+
log: preprocessingLog
565+
})
557566
}
558567

559568
// Add existing properties (regular object type)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const mitigations = {
2323
UNSUPPORTED_HTTP_SECURITY_SCHEME: `Ignore security scheme.`,
2424
NON_APPLICATION_JSON_SCHEMA: `Ignore schema`,
2525
OBJECT_MISSING_PROPERTIES: `The (sub-)object will be stored in an arbitray JSON type.`,
26+
UNSUPPORTED_JSON_SCHEMA_KEYWORD: `Ignore keyword and continue.`,
2627

2728
// Links
2829
UNRESOLVABLE_LINK: `Ignore link.`,

0 commit comments

Comments
 (0)