forked from yarax/swagger-to-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for allOf directive from OpenAPI v3. Addresses issue yara…
- Loading branch information
1 parent
4796b5e
commit 8399861
Showing
7 changed files
with
221 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
type Mutation { | ||
allOfTest_put(body: param_allOfTest_put_bodyInput): TestBody1! | ||
} | ||
|
||
input param_allOfTest_put_bodyInput { | ||
int1: String | ||
string1: String | ||
enum1: String | ||
bool1: Boolean | ||
int3: String | ||
string3: String | ||
enum3: String | ||
bool3: Boolean | ||
} | ||
|
||
type Query { | ||
allOfTest_get: [TestBody1!]! | ||
} | ||
|
||
type TestBody1 { | ||
int1: String | ||
string1: String | ||
enum1: String | ||
bool1: Boolean | ||
int2: String | ||
string2: String | ||
enum2: String | ||
bool2: Boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
openapi: 3.0.0 | ||
info: | ||
description: "This is a test schema to test allOf functionality in Swagger" | ||
version: 1.0.0 | ||
title: swagger-to-graphql OpenAPI allOf support | ||
tags: | ||
- name: test | ||
description: This is a test | ||
- name: openapi | ||
description: This supports OpenAPI v3 | ||
paths: | ||
/allOf: | ||
get: | ||
summary: Test that allOf works for schema resolution | ||
operationId: allOfTest_get | ||
responses: | ||
"200": | ||
description: Test Response | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
- $ref: "#/components/schemas/TestCombinedSchema" | ||
"400": | ||
description: Invalid ID supplied | ||
"404": | ||
description: Pet not found | ||
put: | ||
summary: Put test | ||
operationId: allOfTest_put | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
allOf: | ||
- $ref: "#/components/schemas/TestSchema1" | ||
- $ref: "#/components/schemas/TestSchema3" | ||
responses: | ||
"200": | ||
description: Test Response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/TestCombinedSchema" | ||
"400": | ||
description: Invalid ID supplied | ||
"404": | ||
description: Pet not found | ||
|
||
servers: | ||
- url: http://foo.bar/v3 | ||
components: | ||
parameters: | ||
testParam1: | ||
name: testParam1 | ||
in: path | ||
description: A test string parameter | ||
required: true | ||
schema: | ||
type: string | ||
testParam2: | ||
name: testParam2 | ||
in: path | ||
description: A test integer parameter | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
requestBodies: | ||
TestBody1: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/TestCombinedSchema" | ||
description: List of user object | ||
required: true | ||
TestBody2: | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
allOf: | ||
- $ref: "#/components/schemas/TestSchema1" | ||
- $ref: "#/components/schemas/TestSchema2" | ||
description: List of user object | ||
required: true | ||
schemas: | ||
TestSchema1: | ||
type: object | ||
properties: | ||
int1: | ||
type: integer | ||
format: int64 | ||
string1: | ||
type: string | ||
format: date-time | ||
enum1: | ||
type: string | ||
enum: | ||
- aaaa | ||
- bbbb | ||
- cccc | ||
bool1: | ||
type: boolean | ||
default: false | ||
TestSchema2: | ||
type: object | ||
properties: | ||
int2: | ||
type: integer | ||
format: int64 | ||
string2: | ||
type: string | ||
format: date-time | ||
enum2: | ||
type: string | ||
enum: | ||
- aaaa | ||
- bbbb | ||
- cccc | ||
bool2: | ||
type: boolean | ||
default: false | ||
TestSchema3: | ||
type: object | ||
properties: | ||
int3: | ||
type: integer | ||
format: int64 | ||
string3: | ||
type: string | ||
format: date-time | ||
enum3: | ||
type: string | ||
enum: | ||
- aaaa | ||
- bbbb | ||
- cccc | ||
bool3: | ||
type: boolean | ||
default: false | ||
TestCombinedSchema: | ||
allOf: | ||
- $ref: "#/components/schemas/TestSchema1" | ||
- $ref: "#/components/schemas/TestSchema2" |
I have the same problem as you. swagger-to-graphql doesn't support allOf. I have tried your commit with https://www.botswagger.com/swaggers/tmb.json but it doesn't work. Item has a model like this:
{ allOf: [ { properties: [Object], type: 'object', title: 'FeatureBase' }, { properties: [Object], type: 'object' } ]