hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client
https://heyapi.vercel.app
MIT License
683 stars 52 forks source link

Support openapi 3.1 prefixItems #352

Open orhanhenrik opened 2 months ago

orhanhenrik commented 2 months ago

Description

When using tuples in pydantic in python, it generates openapi spec with prefixItems instead of items.

                    "point": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "number"
                            }
                        ],
                        "title": "Point",
                        "type": "array"
                    },

This should be converted to [number, number] in typescript, but is currently converted to any[] because prefixItems are not recognized.

Same should apply if the types in each position varies (e.g. [number, string]), of course 😄

jordanshatford commented 2 months ago

@orhanhenrik thanks for adding this ticket. I will need to look more into the spec to understand the full details.

Jesperpaulsen commented 2 weeks ago

any updates on this? 😄

mrlubos commented 2 weeks ago

@Jesperpaulsen The update is you might just push me to add this if you keep pinging me 🤣 shouldn't take too long to add

mrlubos commented 2 weeks ago

Oh look, it worked. Try with v0.47.2. Note that it's an incomplete implementation, but it should suffice for the use case provided above. Let me know if you need it to work with other cases

Jesperpaulsen commented 2 weeks ago

That worked like a charm! Thanks a lot @mrlubos 🤠

orhanhenrik commented 2 weeks ago

Works perfectly for our use case, thank you! 🙌

SmithPeder commented 2 weeks ago

Thank you so much for fixing this! 👏🏻