apiron icon indicating copy to clipboard operation
apiron copied to clipboard

Support POST data and response data validation using type-hints or runtime mechanisms

Open daneah opened this issue 5 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I would like my code to be more correct at author time while working with APIs and to fail spectacularly when my code starts sending or receiving unexpected data.

Describe the solution you'd like

I want to know as early as possible that the data I'm sending or receiving is what I expect. Ideally this would be available as type-level information that can be inferred on-the-fly, but second to that a runtime mechanism using e.g. Pydantic would also help.

Describe alternatives you've considered

Today this kind of thing either just isn't thought about a lot, or is done using defensive programming which becomes awfully verbose and isn't guaranteed to be exhaustive.

Additional context

Any implementation should probably be okay with unexpected fields in responses, since this is arguably backward compatible; perhaps there's optional strict checking. For sending data, it seems more likely to want to be strict, since additional fields could theoretically change behavior.

daneah avatar Jul 30 '25 11:07 daneah