Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discriminator mapping can't find schemas using allOf #979

Closed
johannes-riecken opened this issue Jul 18, 2023 · 2 comments · Fixed by #992
Closed

Discriminator mapping can't find schemas using allOf #979

johannes-riecken opened this issue Jul 18, 2023 · 2 comments · Fixed by #992
Labels
bug Something isn't working

Comments

@johannes-riecken
Copy link

What version of ogen are you using?

ogen version v0.71.0 (built with go1.20.4) darwin/arm64

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

github.com/ogen-go/ogen v0.70.0

Can this issue be reproduced with the latest version?

I guess so.

What did you do?

I'm trying to figure out what kind of way to avoid duplication in similar schemas works with ogen. When not nesting allOf and oneOf and not using a discriminator mapping (see here), I get decent code generated. However, if I use a mapping that should be semantically identical to not using a mapping (here), code generation fails.

What did you expect to see?

Successful, possibly even unchanged code generation.

What did you see instead?

INFO	convenient	Convenient errors are not available	{"reason": "operation has no \"default\" response", "at": "openapi_non-injective.yml:14:9"}
generate:
    main.run
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/cmd/ogen/main.go:304
  - build IR:
    main.generate
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/cmd/ogen/main.go:64
  - make ir:
    github.com/ogen-go/ogen/gen.NewGenerator
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/generator.go:112
  - operations:
    github.com/ogen-go/ogen/gen.(*Generator).makeIR
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/generator.go:130
  - path "/circles": get:
    github.com/ogen-go/ogen/gen.(*Generator).makeOps
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/generator.go:171
  - responses:
    github.com/ogen-go/ogen/gen.(*Generator).generateOperation
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/gen_operation.go:55
  - code 200:
    github.com/ogen-go/ogen/gen.(*Generator).generateResponses
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/gen_responses.go:34
  - contents:
    github.com/ogen-go/ogen/gen.(*Generator).responseToIR
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/gen_responses.go:182
  - media: "application/json":
    github.com/ogen-go/ogen/gen.(*Generator).generateContents
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/gen_contents.go:330
  - generate schema:
    github.com/ogen-go/ogen/gen.(*Generator).generateContents.func1
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/gen_contents.go:271
  - item:
    github.com/ogen-go/ogen/gen.(*schemaGen).generate2
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/schema_gen.go:443
  - oneOf:
    github.com/ogen-go/ogen/gen.(*schemaGen).generate2
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/schema_gen.go:204
  - discriminator: unable to map "Rectangle" to "file:///Users/rieckenj/tmp/my-ogen/openapi_non-injective.yml#/components/schemas/Rectangle":
    github.com/ogen-go/ogen/gen.(*schemaGen).oneOf
        /Users/rieckenj/go/pkg/mod/github.com/ogen-go/ogen@v0.71.0/gen/schema_gen_sum.go:289
@johannes-riecken johannes-riecken added the bug Something isn't working label Jul 18, 2023
@dan-j
Copy link

dan-j commented Jul 27, 2023

I've also created this issue, #988, which I think is the same issue as this, somehow I missed this when searching.

@ernado
Copy link
Member

ernado commented Jul 31, 2023

v0.72.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants