io.swagger.models.Response.getDescription()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中io.swagger.models.Response.getDescription方法的一些代码示例,展示了Response.getDescription的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getDescription方法的具体详情如下:
包路径:io.swagger.models.Response
类名称:Response
方法名:getDescription

Response.getDescription介绍

暂无

代码示例

代码示例来源:origin: Swagger2Markup/swagger2markup

descriptionBuilder.text(markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, response.getDescription()));

代码示例来源:origin: apache/servicecomb-java-chassis

public static void correctResponses(Operation operation) {
 int okCode = Status.OK.getStatusCode();
 String strOkCode = String.valueOf(okCode);
 Response okResponse = null;
 for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) {
  Response response = responseEntry.getValue();
  if (StringUtils.isEmpty(response.getDescription())) {
   response.setDescription("response of " + responseEntry.getKey());
  }
  if (operation.getResponses().get(strOkCode) != null) {
   continue;
  }
  int statusCode = NumberUtils.toInt(responseEntry.getKey());
  if ("default".equals(responseEntry.getKey())) {
   statusCode = okCode;
  }
  if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) {
   okResponse = response;
  }
 }
 if (okResponse != null) {
  operation.addResponse(strOkCode, okResponse);
 }
}

代码示例来源:origin: apache/servicecomb-java-chassis

private static void mergeResponse(Operation operation, ResponseConfig responseConfig) {
 if (operation.getResponses() == null) {
  operation.response(responseConfig.getCode(), responseConfig.getResponse());
  return;
 }
 Response response = operation.getResponses().get(String.valueOf(responseConfig.getCode()));
 if (response == null) {
  operation.response(responseConfig.getCode(), responseConfig.getResponse());
  return;
 }
 Response sourceResp = responseConfig.getResponse();
 if (StringUtils.isNotEmpty(sourceResp.getDescription()) && StringUtils.isEmpty(response.getDescription())) {
  response.setDescription(sourceResp.getDescription());
 }
 if (sourceResp.getSchema() != null && response.getSchema() == null) {
  response.setSchema(sourceResp.getSchema());
 }
 if (sourceResp.getExamples() != null && response.getExamples() == null) {
  response.setExamples(sourceResp.getExamples());
 }
 if (sourceResp.getHeaders() != null && response.getHeaders() == null) {
  response.setHeaders(sourceResp.getHeaders());
 }
 if (sourceResp.getVendorExtensions() != null && response.getVendorExtensions() == null) {
  response.setVendorExtensions(sourceResp.getVendorExtensions());
 }
}

代码示例来源:origin: amazon-archives/aws-apigateway-importer

String generateModelName(Response response) {
  return generateModelName(response.getDescription());
}

代码示例来源:origin: io.github.kicksolutions/mock-swagger-core

/**
 * 
 * @param response
 * @return
 */
private MockResponse getRandomExamplesfromResponse(String responseCode, Response response) {
  Map<String, Object> examples = response.getExamples();
  MockResponse mockResponse = null;
  if (examples != null) {
    Random random = new Random();
    List<String> keys = new ArrayList<>(examples.keySet());
    String randomKey = keys.get(random.nextInt(keys.size()));
    mockResponse = new MockResponse(responseCode, examples.get(randomKey), response.getDescription(),
        "application/json");
  } else {
    LOGGER.log(Level.WARNING, "No Example Object Set for ResponseCode " + responseCode);
    mockResponse = new MockResponse(responseCode, null, response.getDescription(), "application/json");
  }
  return mockResponse;
}

代码示例来源:origin: io.syndesis.server/server-api-generator

@Override
public DataShape createShapeFromResponse(final ObjectNode json, final Swagger swagger, final Operation operation) {
  final Optional<Response> maybeResponse = findResponse(operation);
  if (!maybeResponse.isPresent()) {
    return DATA_SHAPE_NONE;
  }
  final Response response = maybeResponse.get();
  final Model responseSchema = response.getResponseSchema();
  final String description = response.getDescription();
  final ObjectNode bodySchema = createSchemaFromModel(json, description, responseSchema);
  return unifiedJsonSchema("Response", "API response payload", bodySchema, null);
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

public static void correctResponses(Operation operation) {
 int okCode = Status.OK.getStatusCode();
 String strOkCode = String.valueOf(okCode);
 Response okResponse = null;
 for (Entry<String, Response> responseEntry : operation.getResponses().entrySet()) {
  Response response = responseEntry.getValue();
  if (StringUtils.isEmpty(response.getDescription())) {
   response.setDescription("response of " + responseEntry.getKey());
  }
  if (operation.getResponses().get(strOkCode) != null) {
   continue;
  }
  int statusCode = NumberUtils.toInt(responseEntry.getKey());
  if ("default".equals(responseEntry.getKey())) {
   statusCode = okCode;
  }
  if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) {
   okResponse = response;
  }
 }
 if (okResponse != null) {
  operation.addResponse(strOkCode, okResponse);
 }
}

代码示例来源:origin: io.syndesis.server/server-connector-generator

@Override
public DataShape createShapeFromResponse(final ObjectNode json, final Swagger swagger, final Operation operation) {
  final Optional<Response> maybeResponse = findResponse(operation);
  if (!maybeResponse.isPresent()) {
    return DATA_SHAPE_NONE;
  }
  final Response response = maybeResponse.get();
  final Model responseSchema = response.getResponseSchema();
  final String description = response.getDescription();
  final JsonNode schema = createSchemaFromModel(json, description, responseSchema);
  String schemaString;
  try {
    schemaString = Json.writer().writeValueAsString(schema);
  } catch (final JsonProcessingException e) {
    throw new IllegalStateException("Unable to serialize given JSON specification in response schema: " + schema, e);
  }
  return new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).name("Response").description("API response payload")
    .specification(schemaString).build();
}

代码示例来源:origin: castlemock/castlemock

/**
 * The method generates a mocked response based on the provided {@link Response} and the
 * <code>httpStatusCode</code>.
 * @param httpStatusCode The HTTP status code that the mocked response will have. Please note that
 *                       any mock response with status code different from OK (200), will be
 *                       marked as disabled.
 * @param response The Swagger response that the mocked response will be based on.
 * @return A new {@link RestMockResponse} based on the provided {@link Response}.
 */
private RestMockResponse generateResponse(final int httpStatusCode, final Response response){
  RestMockResponse restMockResponse = new RestMockResponse();
  restMockResponse.setName(response.getDescription());
  restMockResponse.setHttpStatusCode(httpStatusCode);
  restMockResponse.setUsingExpressions(true);
  if(httpStatusCode == DEFAULT_RESPONSE_CODE){
    restMockResponse.setStatus(RestMockResponseStatus.ENABLED);
  } else {
    restMockResponse.setStatus(RestMockResponseStatus.DISABLED);
  }
  if(response.getHeaders() != null){
    for(Map.Entry<String, Property> headerEntry : response.getHeaders().entrySet()){
      String headerName = headerEntry.getKey();
      HttpHeader httpHeader = new HttpHeader();
      httpHeader.setName(headerName);
      // Swagger does not include an example value for the response.
      restMockResponse.getHttpHeaders().add(httpHeader);
    }
  }
  return restMockResponse;
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

private static void mergeResponse(Operation operation, ResponseConfig responseConfig) {
 if (operation.getResponses() == null) {
  operation.response(responseConfig.getCode(), responseConfig.getResponse());
  return;
 }
 Response response = operation.getResponses().get(String.valueOf(responseConfig.getCode()));
 if (response == null) {
  operation.response(responseConfig.getCode(), responseConfig.getResponse());
  return;
 }
 Response sourceResp = responseConfig.getResponse();
 if (StringUtils.isNotEmpty(sourceResp.getDescription()) && StringUtils.isEmpty(response.getDescription())) {
  response.setDescription(sourceResp.getDescription());
 }
 if (sourceResp.getSchema() != null && response.getSchema() == null) {
  response.setSchema(sourceResp.getSchema());
 }
 if (sourceResp.getExamples() != null && response.getExamples() == null) {
  response.setExamples(sourceResp.getExamples());
 }
 if (sourceResp.getHeaders() != null && response.getHeaders() == null) {
  response.setHeaders(sourceResp.getHeaders());
 }
 if (sourceResp.getVendorExtensions() != null && response.getVendorExtensions() == null) {
  response.setVendorExtensions(sourceResp.getVendorExtensions());
 }
}

代码示例来源:origin: swagger-api/swagger-parser

response.setDescription(v2Response.getDescription());

代码示例来源:origin: io.swagger.parser.v3/swagger-parser-v2-converter

response.setDescription(v2Response.getDescription());

代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v2-converter

response.setDescription(v2Response.getDescription());

代码示例来源:origin: io.github.swagger2markup/swagger2markup

descriptionBuilder.text(markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, response.getDescription()));

代码示例来源:origin: com.reprezen.genflow/swagger-doc

_builder.newLineIfNotEmpty();
_builder.append("    ");
String _description = response.getDescription();
String _docHtml = null;
if (_description!=null) {

代码示例来源:origin: com.reprezen.genflow/swagger-doc

_builder.newLineIfNotEmpty();
_builder.append("        ");
String _description = response.getDescription();
String _docHtml = null;
if (_description!=null) {

相关文章