Java Code Examples for io.swagger.annotations.ResponseHeader#response()

The following examples show how to use io.swagger.annotations.ResponseHeader#response() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RpcReaderExtension.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: DubboReaderExtension.java    From swagger-dubbo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: Reader.java    From dorado with Apache License 2.0 5 votes vote down vote up
private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers, JsonView jsonView) {
	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, jsonView);
					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;
}
 
Example 4
Source File: ExtendedSwaggerReader.java    From msf4j with Apache License 2.0 5 votes vote down vote up
private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers) {
    Map<String, Property> responseHeaders = null;
    if (headers != null && headers.length > 0) {
        for (ResponseHeader header : headers) {
            String name = header.name();
            if (!"".equals(name)) {
                if (responseHeaders == null) {
                    responseHeaders = new HashMap<>();
                }
                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;
}