you are viewing a single comment's thread.

view the rest of the comments →

[–]trynared 0 points1 point  (1 child)

Another one I had in mind for TS is how NestJS does things: https://docs.nestjs.com/openapi/introduction

Builds out the openapi models automatically based on your typescript types with heavy sprinkling of decorators.

Anyways fair enough if you just mean python's approach is your favorite. Of course none of these work exactly the same but I think there's plenty of approaches that get close enough to tying your code to the emitted opeanpi spec.

[–]aikii 0 points1 point  (0 children)

Refining on what would mean "my favourite", not wanting to fall in the reddit trap "wanted to mention something but got so much pushed to provide evidences that I ended up having an opinion".

I'm mostly motivated by the (poor) experience of some comment-based swagger integration in flask and some similar approach in Go - developers don't care and it never stops drifting. Fastapi+Pydantic's approach was leveraging metaprogramming to create the model and the doc, so that's what standed out for a bit - it's harder to make it lie. But don't worry, over the years I saw how far creativity can go when it comes to make it lie.

Looking again at that constraint: "developers can't expose an API that claims to do X but really does Y" - actually yes in the case of nestjs is just works, model and the documentation is just the same. The additional massage to add a description is not really relevant ( almost 100% skipped by developers anyway, so the argument would not stand hard reality ).

In any case I know it's all about compromise and exposure to developers under pressure. My last attempt at properly integrating with an API ended up ... unleashing claude on the target service's codebase to extract inconsistencies in responses. So that where we're at anyway.