Skip to content

re-use predetermined item schema #4944

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

Closed
wants to merge 1 commit into from
Closed
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 @@ -548,7 +548,7 @@ public static Optional<Schema> getArraySchema(io.swagger.v3.oas.annotations.medi

if (arraySchema.schema() != null) {
if (arraySchema.schema().implementation().equals(Void.class)) {
getSchemaFromAnnotation(arraySchema.schema(), components, jsonViewAnnotation, openapi31).ifPresent(arraySchemaObject::setItems);
getSchemaFromAnnotation(arraySchema.schema(), components, jsonViewAnnotation, openapi31, arraySchemaObject.getItems()).ifPresent(arraySchemaObject::setItems);
} else if (processSchemaImplementation) {
getSchema(arraySchema.schema(), arraySchema, false, arraySchema.schema().implementation(), components, jsonViewAnnotation, openapi31).ifPresent(arraySchemaObject::setItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public void testOAS31Fields() {
" properties:\n" +
" billingAddress:\n" +
" type: string\n" +
" acceptingCountries:\n" +
" type: array\n" +
" items:\n" +
" type: string\n" +
" description: accepting country\n" +
" enum:\n" +
" - UNITED_STATES_OF_AMERICA\n" +
" - CANADA\n" +
" uniqueItems: true\n" +
"ModelWithOAS31Stuff:\n" +
" type: object\n" +
" $comment: Random comment at schema level\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
package io.swagger.v3.core.resolving.v31.model;

import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;

import java.util.Set;

public class CreditCard {

private String billingAddress;

private Set<Address.CountryEnum> acceptingCountries;

public String getBillingAddress() {
return billingAddress;
}

public void setBillingAddress(String billingAddress) {
this.billingAddress = billingAddress;
}

@ArraySchema(schema = @Schema(description = "accepting country"))
public Set<Address.CountryEnum> getAcceptingCountries() {
return acceptingCountries;
}

public void setAcceptingCountries(Set<Address.CountryEnum> acceptingCountries) {
this.acceptingCountries = acceptingCountries;
}
}