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 Inference: Not generating despite completely unique fields #1185

Open
mattoni opened this issue Feb 23, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@mattoni
Copy link

mattoni commented Feb 23, 2024

What version of ogen are you using?

0.82.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

Ran generator script in my repo to generate client: (cd api-spec; npm run build:public && npm run build:internal) && ./generate.sh

Which has the following line in generate.sh:
go run github.com/ogen-go/ogen/cmd/[email protected] --config=config.json --target client --clean ./api-spec/dist/public-api.yml

All of the types in the union with the issue have unique required fields, yet I get the error below when trying to generate.

Repo in question: https://github.com/cycleplatform/api-client-go

This file is the problem: https://github.com/cycleplatform/api-spec/blob/75211f91a87bdb6457a83df47432edcf099cc003/components/schemas/includes/ComponentsIncludes.yml

If I comment out the last entry (../pipelines/runs/Run.yml) then everything works. Adding that last line back in gives the error. This doesn't make sense, according to the docs (https://ogen.dev/docs/types/sumtype/#unique-fields-discriminator) you need to have unique required fields, which this entry definitely does, so I'm not sure how it can be changed to build a successfully generated client that includes endpoints reliant on this type.

What did you expect to see?

Successful generation of the client.

What did you see instead?

Feature "discriminator inference" is not implemented yet.
Try to create ogen.yml with:

generator:
        ignore_not_implemented: "discriminator inference"

or

generator:
        ignore_not_implemented: ["all"]

to skip unsupported operations.

generation failed:
    main.run
        /home/alex/go/pkg/mod/github.com/ogen-go/[email protected]/cmd/ogen/main.go:308
exit status 1
@mattoni mattoni added the bug Something isn't working label Feb 23, 2024
@tdakkota
Copy link
Member

It does seems like Run has no unique fields.

  • id is defined by many schemes, e.g. ApiKey
  • creator is defined by many schemes, e.g. ApiKey
  • hub_id is defined by many schemes, e.g. ApiKey
  • pipeline_id is defined by TriggerKey too
  • stages is defined by Pipeline too
  • state is defned by many schemes, e.g. ApiKey
  • events is defined by many schemes, e.g. ApiKey
  • variables is defined by Stack too

We should improve error reporting in that case, I think.

@mattoni
Copy link
Author

mattoni commented Feb 26, 2024

I see, I understood it as, no other discriminated type can have all the same fields, not that the summary of them cannot appear across multiple different types. Is it not possible to discriminate based on having ALL the required fields instead?

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

No branches or pull requests

2 participants