Skip to content

Commit 7c5c0d4

Browse files
committed
Update docs
1 parent bc24415 commit 7c5c0d4

File tree

2 files changed

+11
-133
lines changed

2 files changed

+11
-133
lines changed

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,22 @@ By default, openapiTS will generate `updated_at?: string;` because it’s not su
273273

274274
```js
275275
const types = openapiTS(mySchema, {
276-
transform(node: SchemaObject, options): string {
277-
if ("format" in node && node.format === "date-time") {
276+
transform(schemaObject, metadata): string {
277+
if ("format" in schemaObject && schemaObject.format === "date-time") {
278278
return "Date";
279279
}
280280
},
281281
});
282282
```
283283

284-
This will generate `updated_at?: Date` instead. Note that you will still have to do the parsing of your data yourself, but this will save you from having to manually override certain types in your schema. Also be sure to check the `options` parameter for additional context that may be helpful.
284+
That would result in the following change:
285+
286+
```diff
287+
- updated_at?: string;
288+
+ updated_at?: Date;
289+
```
290+
291+
Any [Schema Object](https://spec.openapis.org/oas/latest.html#schema-object) present in your schema will be run through this formatter (even remote ones!). Also be sure to check the `metadata` parameter for additional context that may be helpful.
285292

286293
There are many other uses for this besides checking `format`. Because this must return a **string** you can produce any arbitrary TypeScript code you’d like (even your own custom types).
287294

@@ -291,8 +298,7 @@ There are many other uses for this besides checking `format`. Because this must
291298

292299
1. Support converting any valid OpenAPI schema to TypeScript types, no matter how complicated.
293300
1. This library does **NOT** validate your schema, there are other libraries for that.
294-
1. The generated TypeScript types **must** match your schema as closely as possible (e.g. no renaming to
295-
`PascalCase`)
301+
1. The generated TypeScript types **must** match your schema as closely as possible (e.g. no renaming to `PascalCase`)
296302
1. This library should never require Java, node-gyp, or some other complex environment to work. This should require Node.js and nothing else.
297303
1. This library will never require a running OpenAPI server to work.
298304

docs/migrating-from-v1.md

-128
This file was deleted.

0 commit comments

Comments
 (0)