Skip to content

Commit

Permalink
Fix discriminator propertyName inference (#1342)
Browse files Browse the repository at this point in the history
* Fix discriminator propertyName inference

* Update docs

* Improve tests, fix additional bugs
  • Loading branch information
drwpow committed Sep 13, 2023
1 parent ea553ca commit c17669d
Show file tree
Hide file tree
Showing 13 changed files with 14,454 additions and 4,075 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-numbers-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-typescript": patch
---

Fix discriminator propertyName inference
2 changes: 2 additions & 0 deletions docs/src/content/docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,6 @@ Pet: components["schemas"]["Cat"] | components["schemas"]["Dog"] | components["s
Cat: { type?: "cat"; } & components["schemas"]["PetCommonProperties"];
```
_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._
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.
2,288 changes: 1,566 additions & 722 deletions packages/openapi-typescript/examples/github-api-next.ts

Large diffs are not rendered by default.

0 comments on commit c17669d

Please sign in to comment.