You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
use of AnyOf generates struct type names starting with a number #1121
@Krulknul The issue seems to be in the client code only. Looks like client is generated by default option in v1.13.0. You can try skipping the client code generation by using the command oapi-codegen -package generated -generate types,server,spec api.was.yaml > api.gen.new2.go
Alternatively, if you want to generate the client as well, you can do a small refactoring in the spec file. That should also work. api.was.yaml.txt
I will try to investigate and fix the root cause as my first contribution to this repo 🙂
Activity
daleef-rahman commentedon Jul 3, 2023
@Krulknul The issue seems to be in the client code only. Looks like client is generated by default option in
v1.13.0. You can try skipping the client code generation by using the commandoapi-codegen -package generated -generate types,server,spec api.was.yaml > api.gen.new2.goAlternatively, if you want to generate the client as well, you can do a small refactoring in the spec file. That should also work.
api.was.yaml.txt
I will try to investigate and fix the root cause as my first contribution to this repo 🙂
Fix: Use of AnyOf inline generates struct type names starting with a …
Fix: Use of AnyOf inline generates struct type names starting with a …
jvgutierrez commentedon Apr 2, 2024
I'm hitting this issue trying to generate the client code for USDA Food Central API (https://app.swaggerhub.com/apis/fdcnal/food-data_central_api/1.0.1). Is feasible to work around this issue without modifying the spec?
alejo-rivera commentedon Jul 19, 2024
Found myself here for the same reason. I cloned his fork from #1178 and got a workable client. I look forward to see this finished and merged though!
vasyl-haievyi commentedon Sep 11, 2024
Thank you @alejo-rivera for the suggestion. I also was able to generate a valid client while using the fix. I have faced this issue while working with Hapio APIs - https://docs.hapio.io/hapio-api-definition/Hapio-API.v1.yaml
Generated code was:
fix: correctly generate structs and properties for `anyOf`s (oapi-cod…