spectral icon indicating copy to clipboard operation
spectral copied to clipboard

[Question] [OpenAPI] Regarding `application/x-www-form-urlencoded` request body schema and example validation

Open Marckman opened this issue 3 months ago • 1 comments

Hi Spectral community!

Just opening this in hopes of getting some clarification on how OpenAPI documents are validated.

While doing some tests with Microcks, I found an interesting scenario: for operations with a request body of application/x-www-form-urlencoded content type, documenting examples as objects leads to improper serialization, whereas defining them as strings with the appropriate format (as per OpenAPI example spec, e.g. name1=value1&name2=value2) actually made the tests work.

Now, if I run spectral with Microcks' ruleset after the change, it complains because the schema definition is still of type object; if I change it to string, this could potentially cause other problems, e.g. with code generation.

So for the actual question: could this be a validation problem, or is there a better way of documenting these operations?

Please see the original issue for more context.

Thanks in advance, M

Marckman avatar Sep 03 '25 09:09 Marckman

Just a small addition here: the Microcks' ruleset just uses the Spectral's oas3-valid-media-example with no modification. So the question relates to how this rule is doing validation.

lbroudoux avatar Sep 03 '25 10:09 lbroudoux