openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

Handle "empty" default values as null

Open csbrown-noaa opened this issue 1 month ago • 1 comments

Describe the bug "empty" default values for optional fields throw an error. swagger-parser explicitly allows these (even though they are technically out-of-spec) by converting them silently to null. So, there exist openapi json in the wild built by swagger tools that pass swagger validation, but throw an error here in openapi-python-client.

OpenAPI Spec File https://www.marinespecies.org/rest/api-docs/openapi.yaml

grep for:

                schema:
                    type: integer
                    default: ""

There are three endpoints that have this property. One of which is AphiaTaxonRanksByID. It might be useful to check this endpoint out in the swagger docs here.

Desktop (please complete the following information):

  • openapi-python-client version 0.28.0

Additional context I am in contact with the folks at WORMS to try and find out how their openapi.yaml got this way. Will update here when I get more info.

csbrown-noaa avatar Dec 11 '25 18:12 csbrown-noaa

I have since raised a bug with the folks at WORMS and they have fixed this out-of-spec error. So, my particular use case is moot. Happy to just close this if y'all aren't interested in it.

csbrown-noaa avatar Dec 12 '25 15:12 csbrown-noaa