Skip to content

fix: Fix missing items on nested @ArraySchema items in OAS 3.1 Resolv… #4949

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -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,26 @@ 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" +
" availableCurrencies:\n" +
" type: array\n" +
" items:\n" +
" $ref: \"#/components/schemas/Currency\"\n" +
" description: available currencies\n" +
" uniqueItems: true\n" +
"Currency:\n" +
" type: object\n" +
" properties:\n" +
" currencyCode:\n" +
" type: string\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,8 +1,15 @@
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;
private Set<Currency> availableCurrencies;

public String getBillingAddress() {
return billingAddress;
Expand All @@ -11,4 +18,22 @@ public String getBillingAddress() {
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;
}

@ArraySchema(schema = @Schema(description = "available currencies"))
public Set<Currency> getAvailableCurrencies() {
return availableCurrencies;
}

public void setAvailableCurrencies(Set<Currency> availableCurrencies) {
this.availableCurrencies = availableCurrencies;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.swagger.v3.core.resolving.v31.model;

public class Currency {

private String currencyCode;

public String getCurrencyCode() {
return currencyCode;
}

public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
}
Loading