oapi-codegen
oapi-codegen copied to clipboard
Generate anonymous objects referenced in schemas
Closes #626, #636.
I am very interested to try it, when it is finished, as I think it is solving a similar issue I am experiencing... :+1:
Hi guys, I was wondering if there was any update on that issue ?
@deepmap-marcinr I think I may need a hand with the PascalSchema error, currently trying to work out the intent of those tests to work out what handling needs to be added
I've got this working finally :clap:
If you're happy with it, @deepmap-marcinr, I'll sort out the Git history then merge it.
I'll test it out with a few other specs that have been mentioned to be affected, too
Got a couple of tweaks to make:
- anonymous
requestBodies - ~anonymous
parameters~ - handle when there's i.e.
content: {}
Bump
Is there any updated on this?
It is impacting using go generate for k8s Object DeepCopy etc, as the inlined anonymous structs cannot be consumed to generate the functions.
Simplifying the issue, we have this generated code:
type MyBucket struct {
Spec *struct {
ArchivePeriod *BucketSpecArchivePeriod `json:"archivePeriod,omitempty"`
Cors *struct {
...
}
// other fields
}
when running go generated ./generated we get the following error:
└─( go generate ./generated
command-line-arguments:-: name requested for invalid type: struct{Cors *struct{MaxAgeSeconds *float32 "json:\"maxAgeSeconds,omitempty\""; Methods *[]string "json:\"methods,omitempty\""; Origins *[]string "json:\"origins,omitempty\""; ResponseHeaders *[]string "json:\"responseHeaders,omitempty\""} "json:\"cors,omitempty\""; Status *struct{FromProvider *map[string]interface{} "json:\"fromProvider,omitempty\""} "json:\"status,omitempty\""}
Error: not all generators ran successfully
run `controller-gen object paths=types.gen.go -w` to see all available markers, or `controller-gen object paths=types.gen.go -h` for usage
generated/types.gen.go:6: running "controller-gen": exit status 1
By trying a few different combinations, it appears that the anonymoust structs are the cause of the error.
Thanks!