本文整理了Java中io.swagger.models.Swagger.addDefinition()
方法的一些代码示例,展示了Swagger.addDefinition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.addDefinition()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:addDefinition
暂无
代码示例来源:origin: jooby-project/jooby
swagger.addDefinition(entry.getKey(), doModel(type, entry.getValue()));
代码示例来源:origin: apache/servicecomb-java-chassis
public static void addDefinitions(Swagger swagger, Type paramType) {
Map<String, Model> models = ModelConverters.getInstance().readAll(paramType);
for (Map.Entry<String, Model> entry : models.entrySet()) {
swagger.addDefinition(entry.getKey(), entry.getValue());
}
}
代码示例来源:origin: apache/servicecomb-java-chassis
private RefModel toRefModel(String modelType) {
if (RefProperty.class.isInstance(property)) {
return (RefModel) PropertyBuilder.toModel(property);
}
ModelImpl modelImpl = new ModelImpl();
modelImpl.setType("object");
modelImpl.setName(name);
modelImpl.addProperty(name, property);
operationGenerator.getSwagger().addDefinition(modelType, modelImpl);
RefModel refModel = new RefModel();
refModel.setReference("#/definitions/" + modelType);
return refModel;
}
}
代码示例来源:origin: io.swagger/swagger-models
public Swagger model(String name, Model model) {
this.addDefinition(name, model);
return this;
}
代码示例来源:origin: vmware/admiral
/**
* Add the {@code clazz} model to Swagger. The model is a class annotated with
* {@link ApiModel}. The definition in {@link Swagger} is in the form of a map
* with the keys being the class names and the values - a {@link Model} object
* defined by Swagger. The models contain different {@link io.swagger.models.properties.Property}
* objects which vary depending on the class fields.
*
* @param clazz The class which specifies the model.
*/
private void createApiModel(Class<?> clazz) {
swagger.addDefinition(clazz.getSimpleName(), model(clazz));
}
代码示例来源:origin: org.apache.servicecomb/swagger-generator-core
public static void addDefinitions(Swagger swagger, Type paramType) {
Map<String, Model> models = ModelConverters.getInstance().readAll(paramType);
for (Map.Entry<String, Model> entry : models.entrySet()) {
swagger.addDefinition(entry.getKey(), entry.getValue());
}
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
private void createDefinition(OperationEnum operationEnum, String resourceName, String resourceParentName,
DelegatingResourceHandler<?> resourceHandler) {
String definitionName = getSchemaName(resourceName, resourceParentName, operationEnum);
Model model = null;
Model modelRef = null;
Model modelFull = null;
if (definitionName.endsWith("Get")) {
model = resourceHandler.getGETModel(Representation.DEFAULT);
modelRef = resourceHandler.getGETModel(Representation.REF);
modelFull = resourceHandler.getGETModel(Representation.FULL);
} else if (definitionName.endsWith("Create")) {
model = resourceHandler.getCREATEModel(Representation.DEFAULT);
modelFull = resourceHandler.getCREATEModel(Representation.FULL);
} else if (definitionName.endsWith("Update")) {
model = resourceHandler.getUPDATEModel(Representation.DEFAULT);
}
if (model != null) {
swagger.addDefinition(definitionName, model);
}
if (modelRef != null) {
swagger.addDefinition(definitionName + "Ref", modelRef);
}
if (modelFull != null) {
swagger.addDefinition(definitionName + "Full", modelFull);
}
}
代码示例来源:origin: buremba/netty-rest
public SwaggerReader(Swagger swagger, ObjectMapper mapper, BiConsumer<Method, Operation> swaggerOperationConsumer, Map<Class, PrimitiveType> externalTypes)
{
this.swagger = swagger;
modelConverters = new ModelConverters(mapper);
this.swaggerOperationConsumer = swaggerOperationConsumer;
modelConverters.addConverter(new ModelResolver(mapper));
if (externalTypes != null) {
setExternalTypes(externalTypes);
}
mapper.registerModule(
new SimpleModule("swagger", Version.unknownVersion()) {
@Override
public void setupModule(SetupContext context) {
context.insertAnnotationIntrospector(new SwaggerJacksonAnnotationIntrospector());
}
});
errorProperty = modelConverters.readAsProperty(HttpServer.ErrorMessage.class);
swagger.addDefinition("ErrorMessage", modelConverters.read(HttpServer.ErrorMessage.class).entrySet().iterator().next().getValue());
}
代码示例来源:origin: FINRAOS/herd
swagger.addDefinition(name, model);
model.name(name);
代码示例来源:origin: org.apache.servicecomb/swagger-generator-core
private RefModel toRefModel(String modelType) {
if (RefProperty.class.isInstance(property)) {
return (RefModel) PropertyBuilder.toModel(property);
}
ModelImpl modelImpl = new ModelImpl();
modelImpl.setType("object");
modelImpl.setName(name);
modelImpl.addProperty(name, property);
operationGenerator.getSwagger().addDefinition(modelType, modelImpl);
RefModel refModel = new RefModel();
refModel.setReference("#/definitions/" + modelType);
return refModel;
}
}
代码示例来源:origin: buremba/netty-rest
Map<String, Model> subProperty = modelConverters.read(parameter.getParameterizedType());
String simpleRef = ((RefProperty) property).getSimpleRef();
swagger.addDefinition(simpleRef, subProperty.get(simpleRef));
swagger.addDefinition(entry.getKey(), entry.getValue());
bodyParameter.setSchema(new RefModel(model.getName()));
bodyParameter.setRequired(true);
swagger.addDefinition(name, model);
builder.add(bodyParameter);
代码示例来源:origin: com.gitblit.fathom/fathom-rest-swagger
swagger.addDefinition(modelTag.getName(), model);
代码示例来源:origin: buremba/netty-rest
swagger.addDefinition(name, model);
代码示例来源:origin: buremba/netty-rest
swagger.addDefinition(entry.getKey(), entry.getValue());
代码示例来源:origin: io.swagger/swagger-parser
if(existingModel == null) {
swagger.addDefinition(newRef, model);
cache.addReferencedKey(newRef);
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
private void addDefaultDefinitions() {
// schema of the default response
// received from fetchAll and search operations
swagger.addDefinition("FetchAll", new ModelImpl()
.property("results", new ArrayProperty()
.items(new ObjectProperty()
.property("uuid", new StringProperty())
.property("display", new StringProperty())
.property("links", new ArrayProperty()
.items(new ObjectProperty()
.property("rel", new StringProperty().example("self"))
.property("uri", new StringProperty(StringProperty.Format.URI)))))));
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
@Test
public void swaggerSerializeTest() {
final Info info = new Info().version("1.0.0").title("Swagger WebServices REST");
Swagger swagger = new Swagger().info(info).securityDefinition("basicAuth", new BasicAuthDefinition())
.scheme(Scheme.HTTP).consumes("application/json").produces("application/json");
final Model patientModel = ModelConverters.getInstance().read(Patient.class).get("Patient");
swagger.addDefinition("Patient", patientModel);
final String swaggerJson = Json.pretty(swagger);
assertNotNull(swaggerJson);
}
代码示例来源:origin: com.gitblit.fathom/fathom-rest-swagger
/**
* Manually register the Pippo Error class as Swagger model.
*
* @param swagger
* @return a ref for the Error model
*/
protected RefProperty registerErrorModel(Swagger swagger) {
String ref = Error.class.getSimpleName();
if (swagger.getDefinitions() != null && swagger.getDefinitions().containsKey(ref)) {
// model already registered
return new RefProperty(ref);
}
ModelImpl model = new ModelImpl();
swagger.addDefinition(ref, model);
model.setDescription("an error message");
model.addProperty("statusCode", new IntegerProperty().readOnly().description("http status code"));
model.addProperty("statusMessage", new StringProperty().readOnly().description("description of the http status code"));
model.addProperty("requestMethod", new StringProperty().readOnly().description("http request method"));
model.addProperty("requestUri", new StringProperty().readOnly().description("http request path"));
model.addProperty("message", new StringProperty().readOnly().description("application message"));
if (settings.isDev()) {
// in DEV mode the stacktrace is returned in the error message
model.addProperty("stacktrace", new StringProperty().readOnly().description("application stacktrace"));
}
return new RefProperty(ref);
}
代码示例来源:origin: gitblit/fathom
/**
* Manually register the Pippo Error class as Swagger model.
*
* @param swagger
* @return a ref for the Error model
*/
protected RefProperty registerErrorModel(Swagger swagger) {
String ref = Error.class.getSimpleName();
if (swagger.getDefinitions() != null && swagger.getDefinitions().containsKey(ref)) {
// model already registered
return new RefProperty(ref);
}
ModelImpl model = new ModelImpl();
swagger.addDefinition(ref, model);
model.setDescription("an error message");
model.addProperty("statusCode", new IntegerProperty().readOnly().description("http status code"));
model.addProperty("statusMessage", new StringProperty().readOnly().description("description of the http status code"));
model.addProperty("requestMethod", new StringProperty().readOnly().description("http request method"));
model.addProperty("requestUri", new StringProperty().readOnly().description("http request path"));
model.addProperty("message", new StringProperty().readOnly().description("application message"));
if (settings.isDev()) {
// in DEV mode the stacktrace is returned in the error message
model.addProperty("stacktrace", new StringProperty().readOnly().description("application stacktrace"));
}
return new RefProperty(ref);
}
代码示例来源:origin: vmware/admiral
.schemes(Arrays.asList(new Scheme[] {Scheme.HTTP}));
expectedSwagger.addDefinition("AnnotatedServiceDocumentMock", model);
expectedSwagger.tags(expectedTags.stream().map(tag -> new Tag().name(tag)).collect(Collectors.toList()));
expectedSwagger.path(PATH + "/{id}", getPath);
内容来源于网络,如有侵权,请联系作者删除!