use of io.swagger.annotations.SwaggerDefinition in project java-chassis by ServiceComb.
the class SwaggerDefinitionProcessor method process.
@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
SwaggerDefinition definitionAnnotation = (SwaggerDefinition) annotation;
Swagger swagger = swaggerGenerator.getSwagger();
swaggerGenerator.setBasePath(definitionAnnotation.basePath());
swagger.setHost(definitionAnnotation.host());
convertConsumes(definitionAnnotation, swagger);
convertProduces(definitionAnnotation, swagger);
convertSchemes(definitionAnnotation, swagger);
convertTags(definitionAnnotation, swagger);
convertInfo(definitionAnnotation.info(), swagger);
swagger.setExternalDocs(convertExternalDocs(definitionAnnotation.externalDocs()));
}
use of io.swagger.annotations.SwaggerDefinition in project incubator-servicecomb-java-chassis by apache.
the class SwaggerDefinitionProcessor method process.
@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
SwaggerDefinition definitionAnnotation = (SwaggerDefinition) annotation;
Swagger swagger = swaggerGenerator.getSwagger();
swaggerGenerator.setBasePath(definitionAnnotation.basePath());
swagger.setHost(definitionAnnotation.host());
convertConsumes(definitionAnnotation, swagger);
convertProduces(definitionAnnotation, swagger);
convertSchemes(definitionAnnotation, swagger);
convertTags(definitionAnnotation, swagger);
convertInfo(definitionAnnotation.info(), swagger);
swagger.setExternalDocs(convertExternalDocs(definitionAnnotation.externalDocs()));
}
use of io.swagger.annotations.SwaggerDefinition in project vertx-swagger by bobxwang.
the class Reader method read.
private void read(ReaderContext context) {
Class<?> clasz = context.getCls();
final SwaggerDefinition swaggerDefinition = clasz.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(swaggerDefinition);
}
for (Method method : clasz.getDeclaredMethods()) {
if (!method.isAnnotationPresent(BBRouter.class)) {
continue;
}
final Operation operation = new Operation();
String operationPath = null;
String httpMethod = null;
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
for (ReaderExtension extension : ReaderExtensions.getExtensions()) {
if (operationPath == null) {
operationPath = extension.getPath(context, method);
}
if (httpMethod == null) {
httpMethod = extension.getHttpMethod(context, method);
}
if (operationPath == null || httpMethod == null) {
continue;
}
if (extension.isReadable(context)) {
extension.setDeprecated(operation, method);
extension.applyConsumes(context, operation, method);
extension.applyProduces(context, operation, method);
extension.applyOperationId(operation, method);
extension.applySummary(operation, method);
extension.applyDescription(operation, method);
extension.applySchemes(context, operation, method);
extension.applySecurityRequirements(context, operation, method);
extension.applyTags(context, operation, method);
extension.applyResponses(context, operation, method);
extension.applyImplicitParameters(context, operation, method);
extension.applyExtensions(context, operation, method);
for (int i = 0; i < genericParameterTypes.length; i++) {
extension.applyParameters(context, operation, genericParameterTypes[i], paramAnnotations[i]);
}
}
}
if (httpMethod != null) {
if (operation.getResponses() == null) {
operation.defaultResponse(new Response().description("successful operation"));
}
final Map<String, String> regexMap = new HashMap<>();
final String parsedPath = PathUtils.parsePath(operationPath, regexMap);
final String swaggerPath = getSwaggerPath(parsedPath);
Path path = swagger.getPath(swaggerPath);
if (path == null) {
path = new Path();
swagger.path(swaggerPath, path);
}
path.set(httpMethod.toLowerCase(), operation);
}
}
}
Aggregations