check for dot in path and throw exception if found (#6986)

This commit is contained in:
William Cheng
2017-11-17 20:18:06 +08:00
committed by GitHub
parent 73cb68ee7b
commit 15bbb52b22
9 changed files with 273 additions and 84 deletions

View File

@@ -104,6 +104,15 @@ public class LumenServerCodegen extends AbstractPhpCodegen
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked")
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
for (CodegenOperation op : operations) {
op.httpMethod = op.httpMethod.toLowerCase();
// check to see if the path contains ".", which is not supported by Lumen
// ref: https://github.com/swagger-api/swagger-codegen/issues/6897
if (op.path != null && op.path.contains(".")) {
throw new IllegalArgumentException("'.' (dot) is not supported by PHP Lumen. Please refer to https://github.com/swagger-api/swagger-codegen/issues/6897 for more info.");
}
}
// sort the endpoints in ascending to avoid the route priority issure.
// https://github.com/swagger-api/swagger-codegen/issues/2643