-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
Literal fields are converted to optional any #2019
Comments
@DavidRowthorn I'll need to see the spec you're using to generate the client, are you able to provide it? You can also try running your spec against our fork, this issue might be fixed there. |
@mrlubos I have got the same issue on my end, tried even with your fork but Literal declarations are being generated as optional. However I am not sure if this is entirely generators fault as you see in the schema and not sure if this is somehow configurable during the schema generation. {
"Person":{
"title":"Person",
"type":"object",
"properties":{
"id":{
"title":"Id",
"type":"string"
},
"type":{
"title":"Type",
"default":"Young",
"enum":[
"Young"
],
"type":"string"
},
"created":{
"title":"Created",
"type":"string",
"format":"date-time"
}
},
"required":[
"id",
"created"
// type is not added as required here
...
...
]
}
} |
@elibolonur do you generate spec from code or is it written manually? If code, are you able to share the snippet responsible for the piece that you shared? EDIT: the original post is about literals not being treated as such and outputting any, but you're talking about an optional field, i.e. not the same issue |
@mrlubos Unfortunately not able to share the full schema. This is the part that is treated as optional, with changed names. I could share this part with some changed names fully as well. Also yes, it is not exactly the same. However it is probably still related since literal types are translated as optional anyway. Might not be related to the generator either as said. |
@DavidRowthorn @elibolonur this is fixed in the latest version of |
Using version 0.26.0
A class like the following:
Should generate a typescript class like so:
But it generates
The text was updated successfully, but these errors were encountered: