-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[BUG] [Golang] anyOf results in empty Go struct #2164
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Hello, I'm also blocked due to this issue in one of my development project. If this is not picked up yet, I can volunteer to handle it. A small hand holding or summary of the general area to look at would greatly help. Till then I will explore on my own. Regards |
Hey @mroland91 and @goyalnikhil I think the issue is that the RatType:
type: string
enum:
- NR
- EUTRA
- WLAN
- VIRTUAL You'll see the code generated as you expect: package openapi
type RatType string
// List of RatType
const (
RAT_TYPE_NR RatType = "NR"
RAT_TYPE_EUTRA RatType = "EUTRA"
RAT_TYPE_WLAN RatType = "WLAN"
RAT_TYPE_VIRTUAL RatType = "VIRTUAL"
) |
Hello @fantavlik |
@fantavlik, I'm in similar situation as @goyalnikhil. The definition that I've added as an example is handled by 3GPP and as far as I can see this is a valid OpenAPI spec. I think the generator should handle this case and generate the constants. |
Yup agreed, since this is just equivalent to giving the model a type it seems like a case we should support. I put a PR up for the core fix since this seems to behave the same across languages: #2897 |
Thanks @fantavlik I volunteer to be your beta tester, i will run some tests on your changes to see how it helps. Regards |
Hi @goyalnikhil Were you able to resolve this issue. I am also working on Nchf_Converged_charging and Common_data YAML files and still facing the same issue. Did you use any workaround to overcome this issue? |
Any updates on this? |
Any updates? I've got even worse output for the following "BotMetaIn":
{
"properties":
{
"data":
{
"anyOf":
[
{
"type": "string",
"format": "json-string"
},
{
"type": "object"
}
],
"title": "Data"
},
"expiredAt":
{
"type": "string",
"title": "Expiredat"
}
},
"type": "object",
"required":
[
"data",
"expiredAt"
],
"title": "BotMetaIn"
}, Output: type Data struct {
map[string]interface{} *map[string]interface{}
string *string
} |
Description
When Go model code is generated for an "anyOf" type then the result will be an empty struct.
Yaml:
Actual:
type RatType struct { }
Expected:
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
https://github.com/jdegre/5GC_APIs/blob/7298845c7ede07038838d5c40debb083f929f98b/TS29571_CommonData.yaml#L548
https://github.com/jdegre/5GC_APIs/blob/78b04e48a7fb92b1a5dc6f95419c9ed2f6c3c5ed/TS29518_Namf_MT.yaml#L166
Command line used for generation
./run-in-docker.sh generate -i 5GC_APIs/TS29518_Namf_MT.yaml -g go -o /gen/out -Dmodels
Steps to reproduce
The text was updated successfully, but these errors were encountered: