public void init()

in swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponsesMeta.java [77:117]


  public void init(OpenAPI swagger, Operation operation) {
    if (responseMap.isEmpty()) {
      responseMap.put(Status.OK.getStatusCode(), OBJECT_JAVA_TYPE);
      initGlobalDefaultMapper();
    }

    for (Entry<String, ApiResponse> entry : operation.getResponses().entrySet()) {
      if (entry.getValue().getContent() == null) {
        continue;
      }
      if (entry.getValue().getContent().get(SwaggerConst.DEFAULT_MEDIA_TYPE) == null) {
        continue;
      }

      JavaType javaType = ConverterMgr.findJavaType(swagger,
          SwaggerUtils.getSchema(swagger,
              entry.getValue().getContent().get(SwaggerConst.DEFAULT_MEDIA_TYPE).getSchema()));

      if ("default".equals(entry.getKey())) {
        defaultResponse = javaType;
        continue;
      }

      Integer statusCode = Integer.parseInt(entry.getKey());
      JavaType existing = responseMap.get(statusCode);
      if (existing == null || !ReflectionUtils.isVoid(javaType)) {
        responseMap.put(statusCode, javaType);
      }
    }

    responseMap.putIfAbsent(ExceptionFactory.CONSUMER_INNER_STATUS_CODE, COMMON_EXCEPTION_JAVA_TYPE);
    responseMap.putIfAbsent(ExceptionFactory.PRODUCER_INNER_STATUS_CODE, COMMON_EXCEPTION_JAVA_TYPE);
    responseMap.putIfAbsent(Status.TOO_MANY_REQUESTS.getStatusCode(), COMMON_EXCEPTION_JAVA_TYPE);
    responseMap.putIfAbsent(Status.REQUEST_TIMEOUT.getStatusCode(), COMMON_EXCEPTION_JAVA_TYPE);
    responseMap.putIfAbsent(Status.SERVICE_UNAVAILABLE.getStatusCode(), COMMON_EXCEPTION_JAVA_TYPE);

    if (defaultResponse == null) {
      // swagger中没有定义default,加上default专用于处理exception
      defaultResponse = OBJECT_JAVA_TYPE;
    }
  }