Skip to content

Commit 0eb6691

Browse files
Alan-ChaErikWittern
authored andcommitted
Added operationIdFieldName option
Related to #108 Signed-off-by: Alan Cha <[email protected]>
1 parent 768edca commit 0eb6691

File tree

13 files changed

+194
-29
lines changed

13 files changed

+194
-29
lines changed

packages/oasgraph-cli/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ npm i -g oasgraph-cli
2424
Usage: oasgraph <OAS JSON file path or remote url> [options]
2525
2626
Options:
27-
-V, --version output the version number
28-
-p, --port <port> select the port where the server will start
29-
-u, --url <url> select the base url which paths will be built on
30-
-s, --strict throw an error if OASGraph cannot run without compensating for errors or missing data in the OAS
31-
-a, --addSubOperations nest operations based on path hierarchy
32-
-f, --fillEmptyResponses create placeholder schemas for operations with HTTP status code 204 (no response) rather than ignore them
33-
--cors enable Cross-origin resource sharing (CORS)
34-
--no-viewer do not create GraphQL viewer objects for passing authentication credentials
35-
--save <file path> save schema to path and do not start server
36-
-h, --help output usage information
27+
-V, --version output the version number
28+
-p, --port <port> select the port where the server will start
29+
-u, --url <url> select the base url which paths will be built on
30+
-s, --strict throw an error if OASGraph cannot run without compensating for errors or missing data in the OAS
31+
-a, --addSubOperations nest operations based on path hierarchy
32+
-f, --fillEmptyResponses create placeholder schemas for operations with HTTP status code 204 (no response) rather than ignore them
33+
-o, --operationIdFieldNames create field names based on the operationId
34+
--cors enable Cross-origin resource sharing (CORS)
35+
--no-viewer do not create GraphQL viewer objects for passing authentication credentials
36+
--save <file path> save schema to path and do not start server
37+
-h, --help output usage information
3738
```
3839

3940
The basic usage of the CLI takes the specified OAS, creates a GraphQL interface for it, and starts a server to host the GraphQL interface.

packages/oasgraph-cli/lib/oasgraph.js

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

packages/oasgraph-cli/lib/oasgraph.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/oasgraph-cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
"request": "^2.88.0"
5353
},
5454
"devDependencies": {
55-
"@types/node": "^10.12.0",
56-
"jest": "^23.6.0",
55+
"@types/node": "^11.9.4",
56+
"jest": "^24.1.0",
5757
"standard": "^12.0.1",
5858
"tslint": "^5.11.0",
5959
"tslint-config-standard": "^8.0.1",
60-
"typescript": "^3.1.3"
60+
"typescript": "^3.3.3"
6161
},
6262
"bin": {
6363
"oasgraph": "./lib/oasgraph.js"

packages/oasgraph-cli/src/oasgraph.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ program
2626
.option('-s, --strict', 'throw an error if OASGraph cannot run without compensating for errors or missing data in the OAS')
2727
.option('-a, --addSubOperations', 'nest operations based on path hierarchy')
2828
.option('-f, --fillEmptyResponses', 'create placeholder schemas for operations with HTTP status code 204 (no response) rather than ignore them')
29+
.option('-o, --operationIdFieldNames', 'create field names based on the operationId')
2930
.option('--cors', 'enable Cross-origin resource sharing (CORS)')
3031
.option('--no-viewer', 'do not create GraphQL viewer objects for passing authentication credentials')
3132
.option('--save <file path>', 'save schema to path and do not start server')
@@ -118,7 +119,8 @@ function startGraphQLServer(oas, port) {
118119
viewer: program.viewer,
119120
addSubOperations: program.addSubOperations,
120121
fillEmptyResponses: program.fillEmptyResponses,
121-
baseUrl: program.url
122+
baseUrl: program.url,
123+
operationIdFieldNames: program.operationIdFieldNames
122124
})
123125
.then(({schema, report}) => {
124126
console.log(JSON.stringify(report, null, 2))

packages/oasgraph/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ The options object can contain the following properties:
8181

8282
* `baseUrl` (type: `string`): Used to manual specify the base URL which all paths will be built on. Normally, OASGraph will select a base URL from the [server object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverObject) defined in the OAS. However, if the server object contains multiple URLs, OASGraph will randomly select one. The purpose of this option is to provide greater control over the base URL in these situations, especially when the OAS cannot be modified. This option may also prove to be useful in testing and development.
8383

84+
* `operationIdFieldNames` (type: `boolean`, default: `false`): By default, query field names are based on the return type type name and mutation field names are based on the [`operationId`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#operation-object), which may be generated if it does not exist. This option forces OASGraph to only create field names based on the operationId.
85+
8486
Consider this example of passing options:
8587

8688
```javascript

packages/oasgraph/lib/index.js

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

0 commit comments

Comments
 (0)