@Override public String toModelName(final String name) { final String sanitizedName = sanitizeName(modelNamePrefix + name + modelNameSuffix); // camelize the model name // phone_number => PhoneNumber final String camelizedName = camelize(sanitizedName); // model name cannot use reserved keyword, e.g. return if (isReservedWord(camelizedName)) { final String modelName = "Model" + camelizedName; LOGGER.warn( camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName); return modelName; } // model name starts with number if (name.matches("^\\d.*")) { final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize) LOGGER.warn( name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName); return modelName; } return camelizedName; }
@Override public String toOperationId(String operationId) { // throw exception if method name is empty if (StringUtils.isEmpty(operationId)) { throw new RuntimeException("Empty method/operation name (operationId) not allowed"); } operationId = camelize(sanitizeName(operationId), true); // method name cannot use reserved keyword, e.g. return if (isReservedWord(operationId)) { String newOperationId = camelize("call_" + operationId, true); LOGGER.warn( operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId); return newOperationId; } return operationId; }
@Override public String getSwaggerType(Property p) { String swaggerType = super.getSwaggerType(p); String type; if (typeMapping.containsKey(swaggerType)) { type = typeMapping.get(swaggerType); if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0 || type.equals("Map") || type.equals("List") || type.equals("File") || type.equals("Date")) { return type; } } else { type = swaggerType; } if (null == type) { LOGGER.error("No Type defined for Property " + p); } return toModelName(type); }