Skip to content
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] Required values is nullable #324

Closed
mohachouch opened this issue Jan 26, 2022 · 10 comments · Fixed by #370
Closed

[BUG] Required values is nullable #324

mohachouch opened this issue Jan 26, 2022 · 10 comments · Fixed by #370
Assignees
Labels
bug Something isn't working Triage needed

Comments

@mohachouch
Copy link

Thank you very much for this library

Describe the bug
Required value in swager file is nullable when generating.

To Reproduce
"BrowserInfoPostDto": {
"required": [
"acceptHeader",
"colorDepth",
"javaEnabled",
"javascriptEnabled",
"language",
"timeZoneOffset",
"userAgent"
],
"type": "object",
"properties": {
"acceptHeader": {
"type": "string"
},
"javaEnabled": {
"type": "boolean"
},
"javascriptEnabled": {
"type": "boolean"
},
"language": {
"type": "string"
},
"colorDepth": {
"type": "integer",
"format": "int32"
},
"screenHeight": {
"type": "integer",
"format": "int32"
},
"screenWidth": {
"type": "integer",
"format": "int32"
},
"timeZoneOffset": {
"type": "string"
},
"userAgent": {
"type": "string"
}
},

Output
@jsonkey(name: 'acceptHeader')
final String? acceptHeader;
@jsonkey(name: 'javaEnabled')
final bool? javaEnabled;
@jsonkey(name: 'javascriptEnabled')
final bool? javascriptEnabled;
@jsonkey(name: 'language')
final String? language;
@jsonkey(name: 'colorDepth')
final int? colorDepth;
@jsonkey(name: 'screenHeight')
final int? screenHeight;
@jsonkey(name: 'screenWidth')
final int? screenWidth;
@jsonkey(name: 'timeZoneOffset')
final String? timeZoneOffset;
@jsonkey(name: 'userAgent')
final String? userAgent;

Expected behavior
@jsonkey(name: 'acceptHeader')
final String acceptHeader;
@jsonkey(name: 'javaEnabled')
final bool javaEnabled;
@jsonkey(name: 'javascriptEnabled')
final bool javascriptEnabled;
@jsonkey(name: 'language')
final String language;
@jsonkey(name: 'colorDepth')
final int colorDepth;
@jsonkey(name: 'screenHeight')
final int? screenHeight;
@jsonkey(name: 'screenWidth')
final int? screenWidth;
@jsonkey(name: 'timeZoneOffset')
final String timeZoneOffset;
@jsonkey(name: 'userAgent')
final String userAgent;

Thank you very much for your help

@mohachouch mohachouch added bug Something isn't working Triage needed labels Jan 26, 2022
@Vovanella95
Copy link
Collaborator

Hi @mohachouch

It's expected behaviour for this moment. We generating all required fields nullable. It's needed to have ability to use these models as request parameters, because (at least on our project) we should not send required fields sometimes.

I already have idea how to fix. We will generate separate models for Responses, and such models will have not-nullable fields

@mohachouch
Copy link
Author

Thank you very much for your response and this wonderful work

@fryette
Copy link
Contributor

fryette commented Jan 28, 2022

I would suggest keeping it open to not forget to fix it when we will have two separate models fro request and responses

@fryette fryette reopened this Jan 28, 2022
@samarth-ramesh
Copy link

Hey @Vovanella95, any chance we can get the non-nullable required values (implemented vide #282)?

@Vovanella95
Copy link
Collaborator

Hi @samarth-ramesh , I will try to implement it in a week or two

@samarth-ramesh
Copy link

Ooo, Tysm

@Vovanella95
Copy link
Collaborator

@samarth-ramesh please let us know in case of issues. I have checked it on my swaggers but who knows :D

@samarth-ramesh
Copy link

Works now, thanks a lot :)

@jhancock4d
Copy link

I'm still getting nullable everything in all models created. How do I get it to just respect the swagger file and make any field without a nullable: true not nullable?

@Vovanella95
Copy link
Collaborator

@jhancock4d please share example of swagger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Triage needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants