Skip to content

use of AnyOf generates struct type names starting with a number #1121

@Krulknul

Description

@Krulknul

Trying to compile my schema using this command:
oapi-codegen -package generated openapi/api.yaml > api.gen.go
I'm on version v1.13.0
openapi: 3.0.0

This error is given:

error generating code: error formatting Go code
: generated.go:263:16: '_' must separate successive digits (and 1 more errors)

I've tried to create a minimal example where this issue occurs:

This is a simple schema with cats, dogs and rats.
api.yaml.txt

This is what's written to stderr:
api.gen.go.txt

You can see the error at the top and bottom of the go file.
At line 263 and 320, invalid Go is generated.

This works up until version 1.12.1, but after that, it is broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions