openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Support openapi 3.1 prefixItems

Open orhanhenrik opened this issue 1 year ago • 7 comments

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 😄

orhanhenrik avatar Apr 11 '24 10:04 orhanhenrik

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

jordanshatford avatar Apr 11 '24 11:04 jordanshatford

any updates on this? 😄

Jesperpaulsen avatar Jun 20 '24 11:06 Jesperpaulsen

@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 avatar Jun 20 '24 16:06 mrlubos

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

mrlubos avatar Jun 21 '24 01:06 mrlubos

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

Jesperpaulsen avatar Jun 21 '24 06:06 Jesperpaulsen

Works perfectly for our use case, thank you! 🙌

orhanhenrik avatar Jun 25 '24 07:06 orhanhenrik

Thank you so much for fixing this! 👏🏻

SmithPeder avatar Jun 25 '24 10:06 SmithPeder

Forgot to update here, this is supported in the experimental parser :tada:

mrlubos avatar Nov 11 '24 13:11 mrlubos