当前位置: 首页>>代码示例>>Java>>正文


Java Response.getSchema方法代码示例

本文整理汇总了Java中io.swagger.models.Response.getSchema方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getSchema方法的具体用法?Java Response.getSchema怎么用?Java Response.getSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.swagger.models.Response的用法示例。


在下文中一共展示了Response.getSchema方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResponseList

import io.swagger.models.Response; //导入方法依赖的package包/类
/**
 * @param responseMap
 */
private MyResponse getResponseList(Map.Entry<String, Response> responseMap) {
	MyResponse response;
	String resName = responseMap.getKey();
	Response resValue = responseMap.getValue();
	Property property = resValue.getSchema();

	if(property == null){
		//Response has no schema
		response = createEmptyResponse();
		response.setDescription(resValue.getDescription());
		response.setResponseNumber(resName);
	}
	else {
		if (property instanceof ArrayProperty) {
			ArrayProperty ap = (ArrayProperty) property;
			Property p2 = ap.getItems();
			response = extractSimple(resName, resValue, p2);
		} else {
			response = extractSimple(resName, resValue, property);
		}

	} 
	return response;
}
 
开发者ID:AmadeusITGroup,项目名称:docu.me,代码行数:28,代码来源:ApiData.java

示例2: getModel

import io.swagger.models.Response; //导入方法依赖的package包/类
private Optional<Model> getModel(RestApi api, Response response) {

        String modelName;

        // if the response references a proper model, look for a model matching the model name
        if (response.getSchema() != null && response.getSchema().getType().equals("ref")) {
            modelName = ((RefProperty) response.getSchema()).getSimpleRef();
        } else {
            // if the response has an embedded schema, look for a model matching the generated name
            modelName = generateModelName(response);
        }

        try {
            Model model = api.getModelByName(modelName);
            if (model.getName() != null) {
                return Optional.of(model);
            }
        } catch (Exception ignored) {}

        return Optional.empty();
    }
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:22,代码来源:ApiGatewaySdkSwaggerApiImporter.java

示例3: init

import io.swagger.models.Response; //导入方法依赖的package包/类
public void init(ClassLoader classLoader, String packageName, Swagger swagger, Response response) {
  if (javaType == null) {
    Property property = response.getSchema();
    javaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, property);
  }

  if (response.getHeaders() == null) {
    return;
  }
  for (Entry<String, Property> entry : response.getHeaders().entrySet()) {
    JavaType headerJavaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, entry.getValue());
    headers.put(entry.getKey(), headerJavaType);
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:ResponseMeta.java

示例4: getArrayPropertyFromOperation

import io.swagger.models.Response; //导入方法依赖的package包/类
private Property getArrayPropertyFromOperation(Operation operation) {


        if (operation != null && operation.getResponses() != null) {
            Response response = operation.getResponses().get("200");
            if (response != null) {
                return response.getSchema();
            }
        }
        return null;
    }
 
开发者ID:okta,项目名称:okta-sdk-java,代码行数:12,代码来源:AbstractOktaJavaClientCodegen.java

示例5: createShapeFromResponse

import io.swagger.models.Response; //导入方法依赖的package包/类
static DataShape createShapeFromResponse(final String specification, final Response response) {
    final Property schema = response.getSchema();

    return createShapeFromProperty(specification, schema);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:6,代码来源:DataShapeHelper.java

示例6: getResponseProperty

import io.swagger.models.Response; //导入方法依赖的package包/类
private Property getResponseProperty(Operation operation) {
    Map<String, Response> responses = operation.getResponses();
    Response response = responses.get("200");
    return null == response ? null : response.getSchema();
}
 
开发者ID:Sayi,项目名称:swagger-diff,代码行数:6,代码来源:SwaggerDiff.java

示例7: getResponseTypeInfo

import io.swagger.models.Response; //导入方法依赖的package包/类
/**
 * Returns {@link TypeInfo} corresponding to the response object.
 *
 * <p>In case we cannot resolve the schema we fallback to the following well known types:
 * <li>'Value' type : If there is more than one success response codes or the success code schema
 *     represents a non message type.
 * <li>'List' type : If the response schema represents an array.
 * <li>'Empty' type : If there are no responses or there are no response for success code.
 */
private TypeInfo getResponseTypeInfo(Service.Builder serviceBuilder, Operation operation) {
  if (operation.getResponses() == null) {
    return WellKnownType.EMPTY.toTypeInfo();
  }

  int successCodeCount = 0;
  Response successResponse = null;
  for (String responseCode : operation.getResponses().keySet()) {
    Response response = operation.getResponses().get(responseCode);
    if (isSuccessCode(responseCode)) {
      successCodeCount++;
      if (response.getSchema() != null) {
        successResponse = response;
      }
    } else {
      // TODO (guptasu): Handle other cases like 4xx errors and non-RefProperty Schemas.
    }
  }

  if (successCodeCount == 1 && successResponse != null && successResponse.getSchema() != null) {
    TypeInfo responseTypeInfo =
        typeBuilder.ensureNamed(
            serviceBuilder,
            typeBuilder.getTypeInfo(serviceBuilder, successResponse.getSchema()),
            NameConverter.operationIdToResponseMessageName(operation.getOperationId()));
    if (responseTypeInfo.cardinality() == Cardinality.CARDINALITY_REPEATED) {
      // TODO (guptasu): Seems like we cannot create custom ListValue, something like
      // ListString. Therefore falling back to ListValue. Can we do better than this ?
      return WellKnownType.LIST.toTypeInfo();
    } else if (responseTypeInfo.kind() != Kind.TYPE_MESSAGE) {
      return WellKnownType.VALUE.toTypeInfo();
    } else {
      return responseTypeInfo;
    }
  } else if (successCodeCount == 0) {
    return WellKnownType.EMPTY.toTypeInfo();
  } else {
    // TODO (guptasu): Due to multiple schemas for successful response code  return type for the
    // operation is generalized as Value type.
    return WellKnownType.VALUE.toTypeInfo();
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:52,代码来源:ProtoApiFromOpenApi.java


注:本文中的io.swagger.models.Response.getSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。