karenetheridge / OpenAPI-Modern

Validate HTTP requests and responses against an OpenAPI v3.1 document
https://metacpan.org/release/OpenAPI-Modern/
Other
3 stars 3 forks source link

various types of parameter serialization and types #8

Open karenetheridge opened 2 years ago

karenetheridge commented 2 years ago

https://spec.openapis.org/oas/v3.1.0#parameter-object https://swagger.io/docs/specification/describing-parameters/ https://swagger.io/docs/specification/serialization/

If there is a type: string at the top level of the schema, single parameters get sent as strings and multiple parameters of the same name get sent as arrays (which will cause the validation to fail against a type: string). e.g. use @values = $uri->query_form($param_obj->{name}); $missing = !@values; $values = (@values > 1 ? \@values : $values[0];

If there is a type: integer or type: number at the top level of the schema, consider also converting string values to numbers (if possible) so numeric valiation keywords can be used e.g. minimum, multipleOf.

if there is a type: array at the top level of the schema, send single values as an arrayref, e.g. @values = $uri->query_form($param_obj->{name}); $missing = !@values; $values = \@values;

when explode=false, parse style=form parameters foo=1,2,3 as the array [ 1, 2, 3 ].

karenetheridge commented 2 years ago

see also https://metacpan.org/pod/URI::Template https://github.com/OAI/OpenAPI-Specification/issues/1508

Welcome to the challenge of 6570. It works pretty well for serialization. It sucks royally for deserialization. It wasn't intended to work for deserialization. We are at the mercy of URL designers to create URLs that don't suck.