Skip to content
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 @@ -11,7 +11,7 @@

import static io.swagger.parser.util.RefUtils.computeDefinitionName;
import static io.swagger.parser.util.RefUtils.deconflictName;

import static io.swagger.parser.util.RefUtils.isAnExternalRefFormat;

public final class ExternalRefProcessor {

Expand Down Expand Up @@ -64,7 +64,9 @@ public String processRefToExternalDefinition(String $ref, RefFormat refFormat) {
for (Map.Entry<String, Property> prop : subProps.entrySet()) {
if (prop.getValue() instanceof RefProperty) {
RefProperty subRef = (RefProperty) prop.getValue();
subRef.set$ref(processRefToExternalDefinition(subRef.get$ref(), subRef.getRefFormat()));

if(isAnExternalRefFormat(subRef.getRefFormat()))
subRef.set$ref(processRefToExternalDefinition(subRef.get$ref(), subRef.getRefFormat()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ public void testNestedExternalRefs(@Injectable final Model mockedModel){
final String addressURL = "http://my.company.com/path/to/address.json#/definitions/Address";
address.set$ref(addressURL);
custProps.put("Address", address);

//Create a 'local' reference to something in #/definitions, this should be ignored a no longer result in a null pointer exception
final String loyaltyURL = "#/definitions/LoyaltyScheme";

RefProperty loyaltyProp = new RefProperty();
loyaltyProp.set$ref(loyaltyURL);
loyaltyProp.setName("LoyaltyCardNumber");
loyaltyProp.setRequired(true);

custProps.put("Loyalty", loyaltyProp);
customerModel.setProperties(custProps);

//create address model, add Contact Ref Property to it
Expand Down Expand Up @@ -174,6 +184,5 @@ public void testNestedExternalRefs(@Injectable final Model mockedModel){
assertTrue(testedSwagger.getDefinitions().get("Customer")!=null);
assertTrue(testedSwagger.getDefinitions().get("Contact")!=null);
assertTrue(testedSwagger.getDefinitions().get("Address")!=null);
assertTrue(testedSwagger.getDefinitions().size()==3);
}
}