in swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/processor/annotation/ApiResponseMethodProcessor.java [42:77]
public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator,
ApiResponse apiResponse) {
List<String> produces = new ArrayList<>();
String responseCode = apiResponse.responseCode();
if (StringUtils.isEmpty(responseCode) || "default".equals(responseCode)) {
responseCode = SwaggerConst.SUCCESS_KEY;
}
Class<?> type = null;
for (Content content : apiResponse.content()) {
if (StringUtils.isNotEmpty(content.mediaType())) {
produces.add(content.mediaType());
}
if (content.schema() != null && content.schema().implementation() != Void.class) {
type = content.schema().implementation();
}
}
operationGenerator.getOperationGeneratorContext().updateResponse(responseCode,
type == null ? null : SwaggerUtils.resolveTypeSchemas(swaggerGenerator.getOpenAPI(), type));
if (StringUtils.isNotEmpty(apiResponse.description())) {
operationGenerator.getOperationGeneratorContext().updateResponseDescription(responseCode,
apiResponse.description());
}
for (Header header : apiResponse.headers()) {
if (header.schema() == null || header.schema().implementation() == Void.class) {
throw new IllegalArgumentException("@ApiResponse header schema implementation must be defined.");
}
if (StringUtils.isEmpty(header.name())) {
throw new IllegalArgumentException("@ApiResponse header name must be defined.");
}
operationGenerator.getOperationGeneratorContext().updateResponseHeader(responseCode,
header.name(), AnnotationUtils.schemaModel(swaggerGenerator.getOpenAPI(), header.schema()));
}
if (!CollectionUtils.isEmpty(produces)) {
operationGenerator.getOperationGeneratorContext().updateProduces(produces);
}
}