use of io.swagger.models.properties.Property in project java-chassis by ServiceComb.
the class ClassUtils method getOrCreateClass.
// 获取modelImpl对应的class
public static Class<?> getOrCreateClass(ClassLoader classLoader, String packageName, Swagger swagger, ModelImpl modelImpl, String clsName) {
Class<?> cls = getClassByName(classLoader, clsName);
if (cls != null) {
return cls;
}
ClassConfig classConfig = new ClassConfig();
classConfig.setClassName(clsName);
for (Entry<String, Property> entry : modelImpl.getProperties().entrySet()) {
JavaType propertyJavaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, entry.getValue());
classConfig.addField(entry.getKey(), propertyJavaType);
}
cls = JavassistUtils.createClass(classConfig);
return cls;
}
use of io.swagger.models.properties.Property in project java-chassis by ServiceComb.
the class OperationGenerator method scanResponse.
public void scanResponse() {
if (operation.getResponses() != null) {
Response successResponse = operation.getResponses().get(SwaggerConst.SUCCESS_KEY);
if (successResponse != null) {
if (successResponse.getSchema() == null) {
// 标注已经定义了response,但是是void,这可能是在标注上未定义
// 根据函数原型来处理response
Property property = createResponseProperty();
successResponse.setSchema(property);
}
return;
}
}
Property property = createResponseProperty();
Response response = new Response();
response.setSchema(property);
operation.addResponse(SwaggerConst.SUCCESS_KEY, response);
}
use of io.swagger.models.properties.Property in project java-chassis by ServiceComb.
the class ParamUtils method createPendingBodyParameter.
public static PendingBodyParameter createPendingBodyParameter(OperationGenerator operationGenerator, String paramName, Type paramType) {
addDefinitions(operationGenerator.getSwagger(), paramType);
Property property = ModelConverters.getInstance().readAsProperty(paramType);
PendingBodyParameter pendingBodyParameter = new PendingBodyParameter();
pendingBodyParameter.setName(paramName);
pendingBodyParameter.setProperty(property);
pendingBodyParameter.setType(paramType);
pendingBodyParameter.setOperationGenerator(operationGenerator);
return pendingBodyParameter;
}
use of io.swagger.models.properties.Property in project java-chassis by ServiceComb.
the class TestApiResponse method checkApiResponseHeader.
private void checkApiResponseHeader(SwaggerGenerator generator) {
Swagger swagger = generator.getSwagger();
Path path = swagger.getPaths().get("/testApiResponseHeader");
Operation operation = path.getOperations().get(0);
Assert.assertEquals("testApiResponseHeader", operation.getOperationId());
Response response = operation.getResponses().get("200");
Property property = response.getHeaders().get("k1");
Assert.assertEquals(Integer.class, ConverterMgr.findJavaType(generator, property).getRawClass());
property = response.getHeaders().get("k2");
Assert.assertEquals(String.class, ConverterMgr.findJavaType(generator, property).getRawClass());
}
use of io.swagger.models.properties.Property in project java-chassis by ServiceComb.
the class ResponseMeta method init.
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);
}
}
Aggregations