springfox: Schema error: should NOT have additional properties allowEmptyValue

Please take the time to search the repository, if your question has already been asked or answered.

  • Version 2.8

What kind of issue is this?

When I put auto-generated swagger into online swagger editor I get next error

Schema error at definitions[‘MyClass’].properties[‘id’] should NOT have additional properties additionalProperty: allowEmptyValue Jump to line 1523

and

Schema error at definitions[‘MyClass’].properties[‘description’] should NOT have additional properties additionalProperty: allowEmptyValue Jump to line 1523

And class definition is next

public final class MyClass {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @ApiModelProperty(readOnly = true)
    @Setter
    @Getter
    private String id;

    @NotNull
    @ApiModelProperty(required = true)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Setter
    @Getter
    private String description;
}

Definition in swagger is next

MyClass: type: object required: - description properties: description: type: string allowEmptyValue: false id: type: string readOnly: true allowEmptyValue: false title: Source

As I understand allowEmptyValue is not valid property for scheme property. I am using MyClass as @RequestBody. Is it possible to avoid adding allowEmptyValue to property definition? In my case I have @NotNull and required = true, but none of them says value cannot be empty

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (9 by maintainers)

Most upvoted comments

@amfine-soft-drault end of this month

This regression is a huge breaking change, hopefully will be addressed as such.

+1

Once you set @ApiModelProperty() for a entity field, the YAML generation adds allowEmptyValue to Entity schema definition. It does this regardless if you actually set the allowEmptyValue field in the @ApiModelProperty or not.

Its been fixed and will be released shortly

@dilipkrish, please reopen this. In 2.9.2, spring fox still producing “allowEmptyValue” in generated spec for @ApiModelProperty annotation. Thanks.

My only solution for this was to roll back to 2.7.0 where this invalid property was not being generated; and "allowEmptyValue " is not valid OpenAPI spec as far as I can tell,

The editor.swagger.io will reject files with invalid properties such as this and we have automated processes that validate swagger files in order to use various other tools with valid API spec files

Hi just to be sure, did you mean end-of-march or end-of-april ?

Upgrading below versions removed the error in gradle for me

compile group: ‘io.springfox’, name: ‘springfox-swagger2’, version: ‘2.9.2’ compile group: ‘io.springfox’, name: ‘springfox-swagger-ui’, version: ‘2.9.2’

Forgive @dilipkrish.

I was about to add another comment explaining that having done further tests I can confirm that 2.9.0 corrects this issue.

I had messed my pom and despite thinking I was using 2.9.0, I was actually still using 2.8.0 during the application execution.

Thanks for reporting @igorko