You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason for all the `["…"]` everywhere is because OpenAPI lets you use more characters than are valid TypeScript identifiers. The goal of this project is to generate _all_ of your schema, not merely the parts that are “TypeScript-safe.”
77
+
Because OpenAPI schemas may have invalid TypeScript characters as names, the square brackets are a safe way to access every property.
75
78
76
79
Also note that there’s a special `operations` interface that you can import `OperationObjects` by their [operationId][openapi-operationid]:
77
80
@@ -81,11 +84,13 @@ import { operations } from './generated-schema.ts';
81
84
typegetUsersById=operations["getUsersById"];
82
85
```
83
86
84
-
This is the only place where our generation differs from your schema as-written, but it’s done so as a convenience and shouldn’t cause any issues (you can still use deep references as-needed).
87
+
Even though `operations` isn’t present in your original schema, it’s a simple convenience and won’t disrupt any of your other types.
88
+
89
+
_Thanks to [@gr2m](https://github.com/gr2m) for the operations feature!_
85
90
86
-
_Thanks to @gr2m for the operations feature!_
91
+
#### Outputting to stdout
87
92
88
-
#### Outputting to `stdout`
93
+
Simply omit the `--output` flag to return to stdout:
89
94
90
95
```bash
91
96
npx openapi-typescript schema.yaml
@@ -113,21 +118,21 @@ npm i --save-dev openapi-typescript
The Node API may be useful if dealing with dynamically-created schemas, or you’re using within context of a larger application. Pass in either a JSON-friendly object to load a schema from memory, or a string to load a schema from a local file or remote URL (it will load the file quickly using built-in Node methods). Note that a YAML string isn’t supported in the Node.js API; either use the CLI or convert to JSON using [js-yaml][js-yaml] first.
129
134
130
-
⚠️ As of `v3.3`, this is an async function.
135
+
⚠️ As of `v4.0`, `openapiTS()` is an async function.
0 commit comments