better error message when parameter ref not defined (#1837)

This commit is contained in:
William Cheng 2019-01-07 23:29:13 +08:00 committed by Akihito Nakano
parent 1ef56b44c2
commit b7971e2e3d

View File

@ -4191,6 +4191,9 @@ public class DefaultCodegen implements CodegenConfig {
protected Parameter getParameterFromRef(String ref, OpenAPI openAPI) {
String parameterName = ref.substring(ref.lastIndexOf('/') + 1);
Map<String, Parameter> parameterMap = openAPI.getComponents().getParameters();
if (parameterMap == null ) { // can't find the ref
throw new RuntimeException(ref + " not defined in the spec.");
}
return parameterMap.get(parameterName);
}