本文整理汇总了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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
}