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

Default "optional" is displayed on all fields on response classes. #1601

Closed
Zoooook opened this issue Sep 15, 2015 · 6 comments
Closed

Default "optional" is displayed on all fields on response classes. #1601

Zoooook opened this issue Sep 15, 2015 · 6 comments

Comments

@Zoooook
Copy link

Zoooook commented Sep 15, 2015

All fields default to optional and you have to explicitly make them required to override the default. Without an option to change the default, we at least need to be able to not display "optional" on every single field, without explicitly marking every field as required. That's the whole point of defaults, you don't have to explicitly state them.

@mar612
Copy link

mar612 commented Sep 16, 2015

Basically, you'd rather have the required fields labelled as 'required', while having the optional fields not labelled, correct?

@Zoooook
Copy link
Author

Zoooook commented Sep 17, 2015

Yes

@webron
Copy link
Contributor

webron commented Sep 21, 2015

I'm confused by what you mean here, are you referring to optional in the model view part?

@mar612
Copy link

mar612 commented Sep 21, 2015

Yeah, I think that's what OP is referring to.

@remesh22
Copy link

Without explicitly making all the fields as required using the annotation @ApiModelProperty(required = true),
is there a way to make all the fields as required by default so that i can expose the optional fields using @ApiModelProperty(required = false).In order to make one filed optional(openConnectSessionId), i am ending up with making all the other fields as required now as below:
public class LoginVO {

@JsonProperty("open_connect_session_id")
private String openConnectSessionId;
@ApiModelProperty(required = true)
@JsonProperty("ip_address")
private String ipAddress;
@ApiModelProperty(required = true)
private String username;
@ApiModelProperty(required = true)
private String password;

}

@webron
Copy link
Contributor

webron commented Jan 13, 2017

That's a question to swagger-core really, but the answer is no.

@webron webron closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants