Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@
**/
String example() default "";

/**
* Set value of example to null if array contains the value of example
*
* @return Array of string that each element must be set to null if it equals example
*/
String[] nullValues() default {};

/**
* Additional external documentation for this schema.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,18 @@ protected Object resolveExample(Annotated a, Annotation[] annotations, io.swagge
return null;
}

protected Boolean resolveNullValues(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) {
if (schema != null) {
for (String nullValue : schema.nullValues()) {
if (nullValue.equals(schema.example())) {
return true;
}
}
}

return false;
}

protected io.swagger.v3.oas.annotations.media.Schema.RequiredMode resolveRequiredMode(io.swagger.v3.oas.annotations.media.Schema schema) {
if (schema != null && !schema.requiredMode().equals(io.swagger.v3.oas.annotations.media.Schema.RequiredMode.AUTO)) {
return schema.requiredMode();
Expand Down Expand Up @@ -2801,6 +2813,10 @@ protected void resolveSchemaMembers(Schema schema, Annotated a, Annotation[] ann
if (example != null) {
schema.example(example);
}
Boolean nullValue = resolveNullValues(a, annotations, schemaAnnotation);
if (nullValue) {
schema.example(null);
}
Boolean readOnly = resolveReadOnly(a, annotations, schemaAnnotation);
if (readOnly != null) {
schema.readOnly(readOnly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,14 @@ public String example() {
return patch.example();
}

@Override
public String[] nullValues() {
if (master.nullValues().length > 0 || patch.nullValues().length == 0) {
return master.nullValues();
}
return patch.nullValues();
}

@Override
public io.swagger.v3.oas.annotations.ExternalDocumentation externalDocs() {
if (getExternalDocumentation(master.externalDocs()).isPresent() || !getExternalDocumentation(patch.externalDocs()).isPresent()) {
Expand Down