OpenAPITools / OpenAPITools/openapi-generator
[BUG][GO] Discriminator not rendering
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I've added a discriminator to our openAPI spec, and I can't seem to get the generated client to unmarshal the response properly.
❯ go run main.go
panic: unable to unmarshal data into slo.SloResponse: data matches more than one schema in oneOf(SloResponseIndicator)
goroutine 1 [running]:
main.main()
/Users/nick/work/busted-slo-parsing/main.go:149 +0x148
exit status 2
I would expect some code in this file to check the type field and unmarshal it appropriately.
openapi-generator version
❯ docker run --rm openapitools/openapi-generator-cli:latest version
7.0.0-SNAPSHOT
OpenAPI declaration file content or url
https://github.com/wandergeek/busted-slo-parsing/blob/master/bundled.yaml#L1341-L1353
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
-i /local/bundled.yaml \
--git-repo-id terraform-provider-elasticstack \
--git-user-id elastic \
-p isGoSubmodule=true \
-p packageName=slo \
-p generateInterfaces=true \
-g go \
-o /local/generated/slo
Steps to reproduce
git clone git@github.com:wandergeek/busted-slo-parsing.git
cd busted-slo-parsing
make generate-slo-client
go run main.go
Have I just specified this incorrectly? Any help much appreciated!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the bundled.yaml spec using the documented Docker generation command, then run main.go. Start with generated/slo/model_slo_response_indicator.go and compare the discriminator declaration at bundled.yaml lines 1341-1353 with the generated unmarshalling behavior. Done means the generated Go client unmarshals the response without the multiple-schema panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100