ogen-go / ogen

OpenAPI v3 code generator for go

Home Page:https://ogen.dev

Repository from Github https://github.comogen-go/ogenRepository from Github https://github.comogen-go/ogen

bug go:generate:nvalid schema.type:style:explode combination

blueo opened this issue · comments

What version of ogen are you using?

$ go list -m github.com/ogen-go/ogen

github.com/ogen-go/ogen v1.4.0

Can this issue be reproduced with the latest version?

yes

What did you do?

Attempting to generate code from an OpenAPI 3.1 json file (generated from FastAPI) using

go:generate go run github.com/ogen-go/ogen/cmd/ogen --target openapi_internal -package internalapi --clean http://localhost:8000/_internal/v1/openapi.json

What did you expect to see?

An error that might help me find what is wrong with my open api spec or configuration

What did you see instead?

A more general error that I can't seem to narrow down what is wrong: openapi.json:1:933 -> invalid schema.type:style:explode combination: ("null":"form":true) followed by a dump of my spec. Eg:
image

at character 933 there is a null type [{"type":"integer"},{"type":"null"}],"title":"Token"}}] which seems to be ok on another spec that I have

any clues to narrow down what's going wrong would be great.

It seems JSON spec you are using is minimized and does not contain any newlines. Try to format spec before running ogen.

invalid schema.type:style:explode combination: ("null":"form":true) says that spec have a parameter or urlencoded form field of type null. ogen does not support null parameters, since they are not properly defined by Open API spec.

Thanks, the newlines helped to track it down.
It does indeed seem to be because of the null type on a parameter which as you say is unsupported.

Nullable params doesn't appear to be much of a topic outside of that issue - so i guess people ether don't use them or its assumed there is some handling of null values (the linked rfc appears to indicate this). I guess this would be nice as its probably common for optional params to get a 'null' type