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

@Hidden does not work for fields named in upper camel case style #3560

Closed
Strunevskiy opened this issue May 14, 2020 · 4 comments · Fixed by #3706
Closed

@Hidden does not work for fields named in upper camel case style #3560

Strunevskiy opened this issue May 14, 2020 · 4 comments · Fixed by #3706

Comments

@Strunevskiy
Copy link

Strunevskiy commented May 14, 2020

When there are fields named in upper camel case style using @JsonProperty annotation that is marked by Hidden annotation , fields are displayed on swagger-ui

public class Foo {

	@Schema(name = "FirstName", hidden = true)
	@JsonProperty(value = "FirstName")
	@Hidden
	private String firstName;

	@JsonProperty(value = "lastName")
	private String lastName;

	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
}
ResolvedSchema resolvedSchema = ModelConverters.getInstance()
		.resolveAsResolvedSchema(new AnnotatedType(Foo.class));
if (resolvedSchema.schema != null) {
	Schema schemaN = resolvedSchema.schema;
	Map<String, Schema> schemaMap = resolvedSchema.referencedSchemas;
	Assert.assertTrue( schemaMap.get("Foo").getProperties().size()==1, "Foo should only contain lastName");

}
@rgroothuijsen
Copy link

This appears to actually be the result of @JsonProperty rather than any particular naming conventions. When I add @Hidden to the getter and setter as well, the field disappears again.

@Strunevskiy
Copy link
Author

@rgroothuijsen do I understand you correctly if I add @hidden to the setter and getter the field will disappear ?

@rgroothuijsen
Copy link

Yes, that's what I found.

@frantuma
Copy link
Member

Thanks for reporting this. should be fixed in #3706, please see comment there about behaviour change.

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

Successfully merging a pull request may close this issue.

3 participants