ogen icon indicating copy to clipboard operation
ogen copied to clipboard

Generation Error after Upgrading to v1.12.0 or v1.11.0 - generation fails with a conflict.

Open TomerHeber opened this issue 8 months ago • 2 comments

What version of ogen are you using?

1.12.0 and 1.11.0

Can this issue be reproduced with the latest version?

Yes (with my spec file)

What did you do?

I attempted to generate code from the spec file.

//go:generate go run github.com/ogen-go/ogen/cmd/ogen --target ./client -package client --clean openapi.json

What did you expect to see?

Successful code generation. Code generation is successful in version github.com/ogen-go/ogen v1.10.1 degradation occurred between v1.10.1 and v1.11.0

What did you see instead?

generate:
    main.run
        /Users/tomerheber/go/pkg/mod/github.com/ogen-go/[email protected]/cmd/ogen/main.go:378
  - build IR:
    main.generate
        /Users/tomerheber/go/pkg/mod/github.com/ogen-go/[email protected]/cmd/ogen/main.go:71
  - make ir:
    github.com/ogen-go/ogen/gen.NewGenerator
        /Users/tomerheber/go/pkg/mod/github.com/ogen-go/[email protected]/gen/generator.go:110
  - operations:
    github.com/ogen-go/ogen/gen.(*Generator).makeIR
        /Users/tomerheber/go/pkg/mod/github.com/ogen-go/[email protected]/gen/generator.go:128
  - anonymous type name conflict: "OptSecretConfig":
    github.com/ogen-go/ogen/gen.(*tstorage).merge
        /Users/tomerheber/go/pkg/mod/github.com/ogen-go/[email protected]/gen/tstorage.go:180

TomerHeber avatar Apr 19 '25 02:04 TomerHeber

I suspect this might be the root cause: https://github.com/ogen-go/ogen/issues/1338 #1444

TomerHeber avatar Apr 19 '25 02:04 TomerHeber

I'm not sure if the root cause is the same, but I'm getting a similar error for the example below (make ir: operations: anonymous type name conflict: "OptObj"). Removing "nullable": true, for Obj fixes the error.

{
  "openapi": "3.0.3",
  "info": {
    "version": "latest"
  },
  "paths": {
    "/v1": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Nullable"
                }
              }
            }
          }
        }
      }
    },
    "/v2": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotNullable"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Obj": {
        "nullable": true,
        "type": "object"
      },
      "Nullable": {
        "nullable": true,
        "type": "object",
        "properties": {
          "obj": {
            "$ref": "#/components/schemas/Obj"
          }
        }
      },
      "NotNullable": {
        "type": "object",
        "properties": {
          "obj": {
            "$ref": "#/components/schemas/Obj"
          }
        }
      }
    }
  }
}

mxk avatar May 09 '25 17:05 mxk