Skip to content

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

@pppwaw

Description

@pppwaw

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions