oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

error resolving primitive type: invalid format (true) for boolean

Open pppwaw opened this issue 6 months ago • 0 comments

When using oapi-codegen to generate code from https://openapi.logto.io/, I encountered this error:

error generating code: error creating operation definitions: error generating body definitions: error generating request body definition: error generating Go schema for property 'mfaSkipped': error resolving primitive type: invalid format (true) for boolean

The relevant part of the spec looks like this:

"mfaSkipped": {
  "type": "boolean",
  "format": "true"
}

As far as I can tell, this is trying to indicate that the field must be the literal boolean true. While this is valid in OpenAPI, Go doesn’t support constraining booleans to literal values, and oapi-codegen seems to fail when encountering this.

TypeScript-based generators like hey-api just ignore this kind of constraint. Would it be possible for oapi-codegen to do the same (e.g. treat this as a regular bool), or at least not fail on it?

Thanks!

pppwaw avatar Aug 05 '25 14:08 pppwaw