Search in sources :

Example 1 with ResponseHeader

use of io.swagger.annotations.ResponseHeader in project swagger-core by swagger-api.

the class ServletReaderExtension method parseResponseHeaders.

private static Map<String, Property> parseResponseHeaders(ReaderContext context, ResponseHeader[] headers) {
    Map<String, Property> responseHeaders = null;
    for (ResponseHeader header : headers) {
        final String name = header.name();
        if (StringUtils.isNotEmpty(name)) {
            if (responseHeaders == null) {
                responseHeaders = new HashMap<String, Property>();
            }
            final Class<?> cls = header.response();
            if (!ReflectionUtils.isVoid(cls)) {
                final Property property = ModelConverters.getInstance().readAsProperty(cls);
                if (property != null) {
                    final Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(), property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
                    responseProperty.setDescription(header.description());
                    responseHeaders.put(name, responseProperty);
                    appendModels(context.getSwagger(), cls);
                }
            }
        }
    }
    return responseHeaders;
}
Also used : ResponseHeader(io.swagger.annotations.ResponseHeader) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) MapProperty(io.swagger.models.properties.MapProperty) RefProperty(io.swagger.models.properties.RefProperty)

Example 2 with ResponseHeader

use of io.swagger.annotations.ResponseHeader in project swagger-core by swagger-api.

the class Reader method parseResponseHeaders.

private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers) {
    Map<String, Property> responseHeaders = null;
    if (headers != null) {
        for (ResponseHeader header : headers) {
            String name = header.name();
            if (!"".equals(name)) {
                if (responseHeaders == null) {
                    responseHeaders = new LinkedHashMap<String, Property>();
                }
                String description = header.description();
                Class<?> cls = header.response();
                if (!isVoid(cls)) {
                    final Property property = ModelConverters.getInstance().readAsProperty(cls);
                    if (property != null) {
                        Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(), property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
                        responseProperty.setDescription(description);
                        responseHeaders.put(name, responseProperty);
                        appendModels(cls);
                    }
                }
            }
        }
    }
    return responseHeaders;
}
Also used : ResponseHeader(io.swagger.annotations.ResponseHeader) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) MapProperty(io.swagger.models.properties.MapProperty) RefProperty(io.swagger.models.properties.RefProperty)

Example 3 with ResponseHeader

use of io.swagger.annotations.ResponseHeader in project java-chassis by ServiceComb.

the class ResponseHeaderProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    ResponseHeader responseHeader = (ResponseHeader) annotation;
    ResponseHeaderConfig config = AnnotationUtils.convert(responseHeader);
    if (config != null) {
        Property property = AnnotationUtils.generateResponseHeaderProperty(operationGenerator.getSwagger(), config);
        operationGenerator.addResponseHeader(config.getName(), property);
    }
}
Also used : ResponseHeader(io.swagger.annotations.ResponseHeader) ResponseHeaderConfig(io.servicecomb.swagger.generator.core.processor.annotation.models.ResponseHeaderConfig) Property(io.swagger.models.properties.Property)

Example 4 with ResponseHeader

use of io.swagger.annotations.ResponseHeader in project java-chassis by ServiceComb.

the class ResponseHeadersProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    ResponseHeaders responseHeaders = (ResponseHeaders) annotation;
    MethodAnnotationProcessor processor = operationGenerator.getContext().findMethodAnnotationProcessor(ResponseHeader.class);
    for (ResponseHeader responseHeader : responseHeaders.value()) {
        processor.process(responseHeader, operationGenerator);
    }
}
Also used : ResponseHeader(io.swagger.annotations.ResponseHeader) MethodAnnotationProcessor(io.servicecomb.swagger.generator.core.MethodAnnotationProcessor) ResponseHeaders(io.servicecomb.swagger.extend.annotations.ResponseHeaders)

Aggregations

ResponseHeader (io.swagger.annotations.ResponseHeader)4 Property (io.swagger.models.properties.Property)3 ArrayProperty (io.swagger.models.properties.ArrayProperty)2 MapProperty (io.swagger.models.properties.MapProperty)2 RefProperty (io.swagger.models.properties.RefProperty)2 ResponseHeaders (io.servicecomb.swagger.extend.annotations.ResponseHeaders)1 MethodAnnotationProcessor (io.servicecomb.swagger.generator.core.MethodAnnotationProcessor)1 ResponseHeaderConfig (io.servicecomb.swagger.generator.core.processor.annotation.models.ResponseHeaderConfig)1