scalar / openapi-parser

Modern OpenAPI parser written in TypeScript
MIT License
34 stars 1 forks source link

OpenAPI.Document is not a discriminated union and I wish it was one #158

Closed tmcw closed 3 months ago

tmcw commented 3 months ago

What happens?

Per #157 this is kind of a feature request, but discussions aren't turned on.

When I run a document through deference or upgrade, I get the OpenAPI.Document type. This type contains a bunch of union fields, like .paths is a union between all possible paths types:

CleanShot 2024-07-09 at 12 53 44@2x

It'd be ideal to:

As it is, it's tricky to work with the types because they are too flexible.

What did you expect to happen?

These types would be discriminated

How can we reproduce the issue?

Swagger/OpenAPI Example

http://

hanspagel commented 3 months ago

Great suggestion! Would you be able to contribute this?

tmcw commented 3 months ago

Yep https://github.com/scalar/openapi-parser/pull/159