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

[Issue 2048] NullPointerException in SchemaProcessor.processArraySchema() #2049

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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 @@ -65,6 +65,9 @@ public void processSchema(Schema schema) {

public void processSchemaType(Schema schema){

if (schema == null) {
return;
}
if (schema instanceof ArraySchema) {
processArraySchema((ArraySchema) schema);
}
Expand Down Expand Up @@ -215,7 +218,7 @@ private void changeDiscriminatorMapping(ComposedSchema composedSchema, String ol
public void processArraySchema(ArraySchema arraySchema) {

final Schema items = arraySchema.getItems();
if (items.get$ref() != null) {
if (items != null && items.get$ref() != null) {
processReferenceSchema(items);
}else{
processSchemaType(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@ public void copyVendorExtensions(Schema source, Schema target) {
}

private boolean isObjectSchema(Schema schema) {
if (schema == null) {
return false;
}
return schema instanceof ObjectSchema
|| "object".equalsIgnoreCase(schema.getType())
|| (schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,4 +1464,13 @@ private static int getDynamicPort() {
return new Random().ints(50000, 60000).findFirst().getAsInt();
}

@Test
public void testResolveArraySchemaItemsNullPointerException() {
final ParseOptions options = new ParseOptions();
options.setResolve(true);
final String actualLocation = "C:/Users/ggregory/git/r/api-gateway/ais-swagger-test-fixtures/src/test/resources/APIs-guru/openapi-directory-master/APIs/clearblade.com/3.0/swagger.yaml";
final OpenAPI output = new OpenAPIV3Parser().read(actualLocation, null, options);
new OpenAPIResolver(output, null, actualLocation).resolve();
}

}
Loading