Skip to content

Commit dad65d9

Browse files
Jennie JiErikWittern
authored andcommitted
Fix #183 field creation should use prop name instead of ref name
Signed-off-by: Jennie Ji <[email protected]>
1 parent 098d279 commit dad65d9

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

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

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/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/src/preprocessor.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ export function preprocessOas(
206206
handleWarning({
207207
typeKey: 'DUPLICATE_OPERATIONID',
208208
message: `Multiple OASs share operations with the same operationId '${operationId}'`,
209-
mitigationAddendum: `The operation from the OAS '${
210-
operation.oas.info.title
211-
}' will be ignored`,
209+
mitigationAddendum: `The operation from the OAS '${operation.oas.info.title}' will be ignored`,
212210
data,
213211
log: preprocessingLog
214212
})
@@ -576,7 +574,7 @@ export function createDataDef(
576574
oas
577575
)
578576
// Add field type references
579-
def.subDefinitions[propSchemaName] = subDefinition
577+
def.subDefinitions[propertyKey] = subDefinition
580578
}
581579
}
582580

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,9 @@ test('Get single resource', () => {
658658
name
659659
address{
660660
street
661+
},
662+
address2{
663+
city
661664
}
662665
}
663666
}`
@@ -668,6 +671,9 @@ test('Get single resource', () => {
668671
name: 'Arlene L McMahon',
669672
address: {
670673
street: '4656 Cherry Camp Road'
674+
},
675+
address2: {
676+
city: 'Macomb'
671677
}
672678
}
673679
}

packages/openapi-to-graphql/test/example_api_server.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ function startServer(PORT) {
2525
street: '4656 Cherry Camp Road',
2626
city: 'Elk Grove Village'
2727
},
28+
address2: {
29+
street: '3180 Little Acres Lane',
30+
city: 'Macomb'
31+
},
2832
employerId: 'binsol',
2933
hobbies: ['tap dancing', 'bowling'],
3034
status: 'staff',
@@ -537,9 +541,7 @@ function startServer(PORT) {
537541
app.post('/api/scanner/:path', (req, res) => {
538542
console.log(req.method, req.path)
539543
res.status(200).send({
540-
body: `req.body: ${req.body}, req.query.query: ${
541-
req.query.query
542-
}, req.path.path: ${req.params.path}`
544+
body: `req.body: ${req.body}, req.query.query: ${req.query.query}, req.path.path: ${req.params.path}`
543545
})
544546
})
545547

packages/openapi-to-graphql/test/fixtures/example_oas.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,9 @@
970970
"address": {
971971
"$ref": "#/components/schemas/address"
972972
},
973+
"address2": {
974+
"$ref": "#/components/schemas/address"
975+
},
973976
"employerId": {
974977
"type": "string",
975978
"description": "The identifier of the company a user works for"

0 commit comments

Comments
 (0)