oasdiff icon indicating copy to clipboard operation
oasdiff copied to clipboard

Adding support for exclusiveMinimum and exclusiveMaximum

Open timonrieger opened this issue 6 months ago • 1 comments

Is your feature request related to a problem? Please describe. exclusiveMinimum and exclusiveMaximum are not yet supported

"allocation": {
    "type": "integer",
    "exclusiveMaximum": 100,
    "exclusiveMinimum": 0,
    "title": "Allocation",
}

Describe the solution you'd like implement the checker/check_response_property_exclusive_max_increased.go and checker/check_response_property_exclusive_min_increased.go as well as for decreased (i guess)

Describe alternatives you've considered Just using minimum, maximum (> 0 is equal to >= 1 for integers)

Additional context I could help with this!

timonrieger avatar Jun 24 '25 00:06 timonrieger

I took a stab at this because I thought it would be trivial, and because I was running into error messages along the lines of "failed to unmarshal data: json error: invalid character 'o' looking for beginning of value, yaml error: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal number into field Schema.exclusiveMinimum of type bool" so I figured that simply adding this pretty boilerplate logic as you have described above would fix it. I drafted that up: https://github.com/elijahcarrel/oasdiff/pull/1.

Unfortunately, it did not help. That error message just shows up in the unit tests I've written in this PR.

Digging in, it looks like the OpenAPI format changed between 3.0 and 3.1 such that "exclusiveMinimum" and "exclusiveMaximum" changed from booleans to numbers (see https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0#:~:text=Tweak%20exclusiveMinimum%20and%20exclusiveMaximum). And oasdiff uses https://github.com/getkin/kin-openapi internally to load OpenAPI schemas, and as documented in a longstanding issue on that repo (https://github.com/getkin/kin-openapi/issues/230), kin-openapi still only supports OpenAPI 3.0, not OpenAPI 3.1.

So I believe #714 cannot be solved without adding this support to the upstream kin-openapi repo.

elijahcarrel avatar Jul 21 '25 03:07 elijahcarrel