public void process()

in oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/ApiResponseMethodAnnotationProcessor.java [33:64]


  public void process(ApiResponse response, OperationContext context) {

    io.swagger.v3.oas.models.responses.ApiResponse apiResponse = new io.swagger.v3.oas.models.responses.ApiResponse();

    Content[] contentAnnotations = response.content();
    Optional.ofNullable(contentAnnotations).ifPresent(contents -> {
      for (Content contentAnnotation : contents) {
        io.swagger.v3.oas.models.media.Content content = new io.swagger.v3.oas.models.media.Content();
        MediaType mediaType = new MediaType();
        content.addMediaType(contentAnnotation.mediaType(), mediaType);
        apiResponse.setContent(content);
      }
    });

    if (StringUtils.isNotEmpty(response.description())) {
      apiResponse.setDescription(response.description());
    } else {
      apiResponse.description("OK");
    }

    Header[] headersAnnotation = response.headers();
    Optional.ofNullable(headersAnnotation).ifPresent(headers -> {
      for (Header headerAnnotation : headers) {
        io.swagger.v3.oas.models.headers.Header header = new io.swagger.v3.oas.models.headers.Header();
        header.description(headerAnnotation.description());
        header.deprecated(headerAnnotation.deprecated());
        apiResponse.addHeaderObject(headerAnnotation.name(), header);
      }
    });

    context.addResponse(response.responseCode(), apiResponse);
  }