@Override public void process(Object annotation, OperationGenerator operationGenerator) { RequestMapping requestMapping = (RequestMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(requestMapping.path(), operationGenerator); this.processPath(requestMapping.value(), operationGenerator); this.processMethod(requestMapping.method(), operationGenerator); this.processConsumes(requestMapping.consumes(), operation); this.processProduces(requestMapping.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { DeleteMapping mappingAnnotation = (DeleteMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.DELETE, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PatchMapping mappingAnnotation = (PatchMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PATCH, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PostMapping mappingAnnotation = (PostMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.POST, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PutMapping mappingAnnotation = (PutMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PUT, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { GetMapping mappingAnnotation = (GetMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.GET, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
public static Class<?> getOrCreateBodyClass(OperationGenerator operationGenerator, List<BodyParameter> bodyParameters) { SwaggerGenerator swaggerGenerator = operationGenerator.getSwaggerGenerator(); Method method = operationGenerator.getProviderMethod(); String clsName = swaggerGenerator.ensureGetPackageName() + "." + method.getName() + "Body"; Class<?> cls = getClassByName(swaggerGenerator.getClassLoader(), clsName); if (cls != null) { return cls; } ClassConfig classConfig = new ClassConfig(); classConfig.setClassName(clsName); // 1.全是预备body // 2.预备body与明确body混合 SwaggerToClassGenerator classGenerator = new SwaggerToClassGenerator(swaggerGenerator.getClassLoader(), swaggerGenerator.getSwagger(), swaggerGenerator.ensureGetPackageName()); for (BodyParameter bp : bodyParameters) { JavaType javaType = ConverterMgr.findJavaType(classGenerator, bp); classConfig.addField(bp.getName(), javaType); } return JavassistUtils.createClass(swaggerGenerator.getClassLoader(), classConfig); }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { GetMapping mappingAnnotation = (GetMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.GET, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PutMapping mappingAnnotation = (PutMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PUT, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { DeleteMapping mappingAnnotation = (DeleteMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.DELETE, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PatchMapping mappingAnnotation = (PatchMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PATCH, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PostMapping mappingAnnotation = (PostMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.POST, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { RequestMapping requestMapping = (RequestMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(requestMapping.path(), operationGenerator); this.processPath(requestMapping.value(), operationGenerator); this.processMethod(requestMapping.method(), operationGenerator); this.processConsumes(requestMapping.consumes(), operation); this.processProduces(requestMapping.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } }
public static Class<?> getOrCreateBodyClass(OperationGenerator operationGenerator, List<BodyParameter> bodyParameters) { SwaggerGenerator swaggerGenerator = operationGenerator.getSwaggerGenerator(); Method method = operationGenerator.getProviderMethod(); String clsName = swaggerGenerator.ensureGetPackageName() + "." + method.getName() + "Body"; Class<?> cls = getClassByName(swaggerGenerator.getClassLoader(), clsName); if (cls != null) { return cls; } ClassConfig classConfig = new ClassConfig(); classConfig.setClassName(clsName); // 1.全是预备body // 2.预备body与明确body混合 SwaggerToClassGenerator classGenerator = new SwaggerToClassGenerator(swaggerGenerator.getClassLoader(), swaggerGenerator.getSwagger(), swaggerGenerator.ensureGetPackageName()); for (BodyParameter bp : bodyParameters) { JavaType javaType = ConverterMgr.findJavaType(classGenerator, bp); classConfig.addField(bp.getName(), javaType); } return JavassistUtils.createClass(swaggerGenerator.getClassLoader(), classConfig); }