forked from loafle/openapi-generator-original
added null checks
This commit is contained in:
@@ -109,11 +109,13 @@ abstract class BasicGenerator extends CodegenConfig with PathUtil {
|
||||
apiListings.foreach(apiDescription => {
|
||||
val basePath = apiDescription.basePath
|
||||
val resourcePath = apiDescription.resourcePath
|
||||
apiDescription.apis.foreach(api => {
|
||||
for ((apiPath, operation) <- ApiExtractor.extractApiOperations(basePath, api)) {
|
||||
output += Tuple3(basePath, apiPath, operation)
|
||||
}
|
||||
})
|
||||
if(apiDescription.apis != null) {
|
||||
apiDescription.apis.foreach(api => {
|
||||
for ((apiPath, operation) <- ApiExtractor.extractApiOperations(basePath, api)) {
|
||||
output += Tuple3(basePath, apiPath, operation)
|
||||
}
|
||||
})
|
||||
}
|
||||
output.map(op => processApiOperation(op._2, op._3))
|
||||
allModels ++= CoreUtils.extractApiModels(apiDescription)
|
||||
})
|
||||
|
||||
@@ -98,18 +98,21 @@ object CoreUtils {
|
||||
val modelNames = new HashSet[String]
|
||||
val modelObjects = new HashMap[String, Model]
|
||||
// return types
|
||||
sd.apis.foreach(api => {
|
||||
if (api.operations != null)
|
||||
api.operations.foreach(op => {
|
||||
modelNames += op.responseClass
|
||||
// POST, PUT, DELETE body
|
||||
if(op.parameters != null)
|
||||
op.parameters.filter(p => p.paramType == "body")
|
||||
.foreach(p => modelNames += p.dataType)
|
||||
if(sd.apis != null){
|
||||
sd.apis.foreach(api => {
|
||||
if (api.operations != null)
|
||||
api.operations.foreach(op => {
|
||||
modelNames += op.responseClass
|
||||
// POST, PUT, DELETE body
|
||||
if(op.parameters != null)
|
||||
op.parameters.filter(p => p.paramType == "body")
|
||||
.foreach(p => modelNames += p.dataType)
|
||||
})
|
||||
})
|
||||
})
|
||||
for ((name, m) <- sd.models)
|
||||
modelObjects += name -> m
|
||||
}
|
||||
if(sd.models != null)
|
||||
for ((name, m) <- sd.models)
|
||||
modelObjects += name -> m
|
||||
|
||||
// extract all base model names, strip away Containers like List[] and primitives
|
||||
val baseNames = (for (modelName <- (modelNames.toList -- primitives))
|
||||
|
||||
Reference in New Issue
Block a user