Skip to content

Commit

Permalink
Do not throw error for anyOf, oneOf, and not
Browse files Browse the repository at this point in the history
Related to #197 and #248

Signed-off-by: Alan Cha <[email protected]>
  • Loading branch information
Alan-Cha committed Oct 3, 2019
1 parent 8a41f9c commit b30dfe2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
21 changes: 18 additions & 3 deletions packages/openapi-to-graphql/lib/preprocessor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/openapi-to-graphql/lib/preprocessor.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/openapi-to-graphql/lib/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export declare const mitigations: {
UNSUPPORTED_HTTP_SECURITY_SCHEME: string;
NON_APPLICATION_JSON_SCHEMA: string;
OBJECT_MISSING_PROPERTIES: string;
UNSUPPORTED_JSON_SCHEMA_KEYWORD: string;
UNRESOLVABLE_LINK: string;
AMBIGUOUS_LINK: string;
LINK_NAME_COLLISION: string;
Expand Down
1 change: 1 addition & 0 deletions packages/openapi-to-graphql/lib/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/openapi-to-graphql/lib/utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 21 additions & 12 deletions packages/openapi-to-graphql/src/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,23 +537,32 @@ export function createDataDef(
if ('allOf' in schema) {
addAllOfToDataDef(def, schema, isInputObjectType, data, oas)
} else if ('anyOf' in schema) {
throw new Error(
`OpenAPI-to-GraphQL currently cannot handle 'anyOf' keyword in '${JSON.stringify(
handleWarning({
typeKey: 'UNSUPPORTED_JSON_SCHEMA_KEYWORD',
message: `OpenAPI-to-GraphQL currently cannot handle 'anyOf' keyword in '${JSON.stringify(
schema
)}'`
)
)}'`,
data,
log: preprocessingLog
})
} else if ('oneOf' in schema) {
throw new Error(
`OpenAPI-to-GraphQL currently cannot handle 'oneOf' keyword in '${JSON.stringify(
handleWarning({
typeKey: 'UNSUPPORTED_JSON_SCHEMA_KEYWORD',
message: `OpenAPI-to-GraphQL currently cannot handle 'oneOf' keyword in '${JSON.stringify(
schema
)}'`
)
)}'`,
data,
log: preprocessingLog
})
} else if ('not' in schema) {
throw new Error(
`OpenAPI-to-GraphQL currently cannot handle 'not' keyword in '${JSON.stringify(
handleWarning({
typeKey: 'UNSUPPORTED_JSON_SCHEMA_KEYWORD',
message: `OpenAPI-to-GraphQL currently cannot handle 'not' keyword in '${JSON.stringify(
schema
)}'`
)
)}'`,
data,
log: preprocessingLog
})
}

// Add existing properties (regular object type)
Expand Down
1 change: 1 addition & 0 deletions packages/openapi-to-graphql/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const mitigations = {
UNSUPPORTED_HTTP_SECURITY_SCHEME: `Ignore security scheme.`,
NON_APPLICATION_JSON_SCHEMA: `Ignore schema`,
OBJECT_MISSING_PROPERTIES: `The (sub-)object will be stored in an arbitray JSON type.`,
UNSUPPORTED_JSON_SCHEMA_KEYWORD: `Ignore keyword and continue.`,

// Links
UNRESOLVABLE_LINK: `Ignore link.`,
Expand Down

0 comments on commit b30dfe2

Please sign in to comment.