Skip to content

Commit c17669d

Browse files
authored
Fix discriminator propertyName inference (#1342)
* Fix discriminator propertyName inference * Update docs * Improve tests, fix additional bugs
1 parent ea553ca commit c17669d

File tree

13 files changed

+14454
-4075
lines changed

13 files changed

+14454
-4075
lines changed

.changeset/friendly-numbers-tease.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-typescript": patch
3+
---
4+
5+
Fix discriminator propertyName inference

docs/src/content/docs/advanced.md

+2
Original file line numberDiff line numberDiff line change
@@ -488,4 +488,6 @@ Pet: components["schemas"]["Cat"] | components["schemas"]["Dog"] | components["s
488488
Cat: { type?: "cat"; } & components["schemas"]["PetCommonProperties"];
489489
```
490490
491+
_Note: you optionally could provide `discriminator.propertyName: "type"` on `Pet` ([docs](https://spec.openapis.org/oas/v3.1.0#discriminator-object)) to automatically generate the `type` key, but is less explicit._
492+
491493
While the schema permits you to use composition in any way you like, it’s good to always take a look at the generated types and see if there’s a simpler way to express your unions & intersections. Limiting the use of `oneOf` is not the only way to do that, but often yields the greatest benefits.

packages/openapi-typescript/examples/github-api-next.ts

+1,566-722
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)