Skip to content

Commit

Permalink
Small changes to improve error reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenko-pavel-a committed Oct 20, 2016
1 parent 1f3c7e6 commit 3ff92f4
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.raml.v2.api.loader.CompositeResourceLoader;
import org.raml.v2.api.loader.ResourceLoader;
import org.raml.v2.api.loader.UrlResourceLoader;
import org.raml.v2.api.model.common.ValidationResult;
import org.raml.v2.api.model.v10.RamlFragment;
import org.raml.v2.internal.impl.RamlBuilder;
import org.raml.v2.internal.impl.commons.RamlHeader;
Expand Down Expand Up @@ -204,8 +205,11 @@ private AbstractType buildSuperType(TopLevelRamlImpl node, TypeExpressionNode tn
}
String typeName = namedNode.getLiteralValue();
if (nameSpace != null) {
AbstractType resolveType = resolveType(node.usesMap.get(nameSpace), typeName);
return resolveType;
LibraryImpl topLevelRamlImpl = node.usesMap.get(nameSpace);
if (topLevelRamlImpl != null) {
AbstractType resolveType = resolveType(topLevelRamlImpl, typeName);
return resolveType;
}
}
AbstractType resolveType = resolveType(node, typeName);
if (resolveType == null && typeName.equals("date")) {
Expand Down Expand Up @@ -312,7 +316,7 @@ private AbstractType innerBuild(TopLevelRamlImpl topLevelRamlImpl, String typeNa
if (n.getName().equals(ITEMS)) {
Node value = n.getValue();
if (value != null) {
AbstractType buildType = buildType(topLevelRamlImpl, "", value, register);
AbstractType buildType = buildType(topLevelRamlImpl, "", value, register);
result.addMeta(new ComponentShouldBeOfType(buildType));
continue;
}
Expand Down Expand Up @@ -351,7 +355,7 @@ private AbstractType innerBuild(TopLevelRamlImpl topLevelRamlImpl, String typeNa
KeyValueNode kv = (KeyValueNode) node;
SimpleTypeNode b = (SimpleTypeNode) kv.getKey();
String literalValue = b.getLiteralValue();
if (literalValue!=null&&literalValue.equals(REQUIRED)) {
if (literalValue != null && literalValue.equals(REQUIRED)) {
Object object = toObject(kv.getValue());
if (object instanceof Boolean) {
Boolean bl = (Boolean) object;
Expand Down Expand Up @@ -594,9 +598,17 @@ public TopLevelRamlImpl build(String ramlBuffer, ResourceLoader loader, String r
} catch (InvalidHeaderException e) {
return null;
}
List<ValidationResult> validationResults = buildApi.getValidationResults();
try{
TopLevelRamlImpl build2 = build(build, header);
build2.setValidationResults(buildApi.getValidationResults());
build2.setValidationResults(validationResults);
return build2;
}catch (Exception e) {
TopLevelRamlImpl build2 = new TopLevelRamlImpl(build);
build2.setValidationResults(validationResults);
e.printStackTrace();
return build2;
}
}

public static TopLevelModel build(String raml) {
Expand Down

0 comments on commit 3ff92f4

Please sign in to comment.