本文整理了Java中io.swagger.models.Swagger.path()
方法的一些代码示例,展示了Swagger.path()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.path()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:path
暂无
代码示例来源:origin: jooby-project/jooby
.orElseGet(() -> {
Path path = new Path();
swagger.path(pattern, path);
return path;
});
代码示例来源:origin: apache/servicecomb-java-chassis
protected void addOperationToSwagger() {
if (StringUtils.isEmpty(httpMethod)) {
return;
}
Path pathObj = swagger.getPath(path);
if (pathObj == null) {
pathObj = new Path();
swagger.path(path, pathObj);
}
HttpMethod hm = HttpMethod.valueOf(httpMethod.toUpperCase(Locale.US));
if (pathObj.getOperationMap().get(hm) != null) {
throw new Error(String.format("Only allowed one default path. %s:%s",
swaggerGenerator.getCls().getName(),
providerMethod.getName()));
}
pathObj.set(httpMethod, operation);
}
}
代码示例来源:origin: kongchen/swagger-maven-plugin
protected void updatePath(String operationPath, String httpMethod, Operation operation) {
if (httpMethod == null) {
return;
}
Path path = swagger.getPath(operationPath);
if (path == null) {
path = new Path();
swagger.path(operationPath, path);
}
path.set(httpMethod, operation);
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
private void addIndividualPath(String resourceParentName, String resourceName, Path path,
String pathSuffix) {
if (!path.getOperations().isEmpty()) {
if (resourceParentName == null) {
swagger.path("/" + resourceName + pathSuffix, path);
} else {
swagger.path("/" + resourceParentName + "/{parent-uuid}/" + resourceName + pathSuffix, path);
}
}
}
代码示例来源:origin: com.vmware.xenon/xenon-swagger
private void addFactory(String uri, ServiceDocument doc) {
this.swagger.path(uri, path2Factory(doc));
if (!this.excludeUtilities) {
this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_STATS, path2UtilStats(null));
this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_CONFIG, path2UtilConfig(null));
this.swagger.path(uri + ServiceHost.SERVICE_URI_SUFFIX_SUBSCRIPTIONS,
path2UtilSubscriptions(null));
this.swagger
.path(uri + ServiceHost.SERVICE_URI_SUFFIX_TEMPLATE, path2UtilTemplate(null));
this.swagger
.path(uri + ServiceHost.SERVICE_URI_SUFFIX_AVAILABLE, path2UtilAvailable(null));
}
Parameter idParam = paramId();
this.swagger.path(uri + PREFIX_ID, path2Instance(doc));
if (!this.excludeUtilities) {
this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_STATS,
path2UtilStats(idParam));
this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_CONFIG,
path2UtilConfig(idParam));
this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_SUBSCRIPTIONS,
path2UtilSubscriptions(idParam));
this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_TEMPLATE,
path2UtilTemplate(idParam));
this.swagger.path(uri + PREFIX_ID + ServiceHost.SERVICE_URI_SUFFIX_AVAILABLE,
path2UtilAvailable(idParam));
}
}
代码示例来源:origin: com.vmware.xenon/xenon-swagger
private void addOperation(String uri, Operation op) {
ServiceDocumentQueryResult q = op.getBody(ServiceDocumentQueryResult.class);
if (q.documents != null) {
Object firstDoc = q.documents.values().iterator().next();
addFactory(uri, Utils.fromJson(firstDoc, ServiceDocument.class));
this.swagger.addTag(this.currentTag);
} else if (q.documentDescription != null
&& q.documentDescription.serviceRequestRoutes != null
&& !q.documentDescription.serviceRequestRoutes.isEmpty()) {
this.swagger
.path(uri, pathByRoutes(q.documentDescription.serviceRequestRoutes.values()));
this.swagger.addTag(this.currentTag);
}
}
代码示例来源:origin: org.apache.servicecomb/swagger-generator-core
protected void addOperationToSwagger() {
if (StringUtils.isEmpty(httpMethod)) {
return;
}
Path pathObj = swagger.getPath(path);
if (pathObj == null) {
pathObj = new Path();
swagger.path(path, pathObj);
}
HttpMethod hm = HttpMethod.valueOf(httpMethod.toUpperCase(Locale.US));
if (pathObj.getOperationMap().get(hm) != null) {
throw new Error(String.format("Only allowed one default path. %s:%s",
swaggerGenerator.getCls().getName(),
providerMethod.getName()));
}
pathObj.set(httpMethod, operation);
}
}
代码示例来源:origin: tminglei/binder-swagger-java
public ExOperation mkOperation(HttpMethod method, String path) {
notEmpty(path, "'path' CAN'T be null or empty!!!");
notEmpty(method, "'method' CAN'T be null or empty!!!");
synchronized (swagger) {
String origPath = path;
path = path.replaceAll("<[^>]+>", "").replaceAll("/:([^/]+)", "/{$1}"); // replace `/:id<[0-9]+>` with `/{id}`
if (swagger.getPath(path) == null) {
logger.info(">>> adding path - '" + path + "'");
swagger.path(path, new Path());
}
Path pathObj = swagger.getPath(path);
if (pathObj.getOperationMap().get(method) != null) {
throw new IllegalArgumentException("DUPLICATED operation - " + method + " '" + path + "'");
}
logger.info(">>> adding operation - " + method + " '" + path + "'");
pathObj.set(method.name().toLowerCase(), new ExOperation(this, method, path));
implemented.put(entry(method, path), true); // set implemented by default
String prevPath = origPaths.put(entry(method, path), origPath);
if (prevPath != null) throw new IllegalArgumentException(
"`" + path + "` was repeatedly defined by `" + prevPath + "` and `" + origPath + "`!!!");
return (ExOperation) pathObj.getOperationMap().get(method);
}
}
代码示例来源:origin: yahoo/elide
swagger.path(pathDatum.getCollectionUrl(), pathDatum.getCollectionPath());
swagger.path(pathDatum.getInstanceUrl(), pathDatum.getInstancePath());
swagger.path(pathDatum.getRelationshipUrl(), pathDatum.getRelationshipPath());
代码示例来源:origin: outbrain/ob1k
throw new UnsupportedOperationException("Unsupported method type " + methodType);
swagger.path(key, path);
代码示例来源:origin: com.outbrain.swinfra/ob1k-swagger
throw new UnsupportedOperationException("Unsupported method type " + methodType);
swagger.path(key, path);
代码示例来源:origin: vmware/admiral
this.swagger.path(path, new io.swagger.models.Path());
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldMakeNonUniqueOperationIdsUnique() {
final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo"))
.post(new Operation().operationId("foo")).put(new Operation().operationId("bar")));
final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(),
createSettingsFrom(swagger));
final List<ConnectorAction> actions = generated.getActions();
assertThat(actions).hasSize(3);
assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo"));
assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1"));
assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar"));
}
代码示例来源:origin: io.syndesis.server/server-api-generator
@Test
public void shouldMakeNonUniqueOperationIdsUnique() {
final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo"))
.post(new Operation().operationId("foo")).put(new Operation().operationId("bar")));
final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(),
createSettingsFrom(swagger));
final List<ConnectorAction> actions = generated.getActions();
assertThat(actions).hasSize(3);
assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo"));
assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1"));
assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar"));
}
代码示例来源:origin: yangfuhai/jboot
if (path == null) {
path = new SwaggerPath();
swagger.path(parsedPath, path);
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldValidateOperationUniqueness() {
final Swagger swagger = new Swagger()
.path("/path", new Path().get(new Operation().operationId("o1")).post(new Operation().operationId("o2")))
.path("/other", new Path().patch(new Operation().operationId("o2")).put(new Operation().operationId("o3")))
.path("/more", new Path().options(new Operation().operationId("o4")).delete(new Operation().operationId("o3")));
final SwaggerModelInfo info = new SwaggerModelInfo.Builder().model(swagger).build();
final SwaggerModelInfo validated = SyndesisSwaggerValidationRules.validateUniqueOperationIds(info);
final List<Violation> warnings = validated.getWarnings();
assertThat(warnings).hasSize(1);
final Violation nonUniqueWarning = warnings.get(0);
assertThat(nonUniqueWarning.error()).isEqualTo("non-unique-operation-ids");
assertThat(nonUniqueWarning.property()).isNull();
assertThat(nonUniqueWarning.message()).isEqualTo("Found operations with non unique operationIds: o2, o3");
}
}
代码示例来源:origin: io.syndesis.server/server-api-generator
@Test
public void shouldValidateOperationUniqueness() {
final Swagger swagger = new Swagger()
.path("/path", new Path().get(new Operation().operationId("o1")).post(new Operation().operationId("o2")))
.path("/other", new Path().patch(new Operation().operationId("o2")).put(new Operation().operationId("o3")))
.path("/more", new Path().options(new Operation().operationId("o4")).delete(new Operation().operationId("o3")));
final SwaggerModelInfo info = new SwaggerModelInfo.Builder().model(swagger).build();
final SwaggerModelInfo validated = SyndesisSwaggerValidationRules.validateUniqueOperationIds(info);
final List<Violation> warnings = validated.getWarnings();
assertThat(warnings).hasSize(1);
final Violation nonUniqueWarning = warnings.get(0);
assertThat(nonUniqueWarning.error()).isEqualTo("non-unique-operation-ids");
assertThat(nonUniqueWarning.property()).isNull();
assertThat(nonUniqueWarning.message()).isEqualTo("Found operations with non unique operationIds: o2, o3");
}
}
代码示例来源:origin: io.syndesis.integration/integration-project-generator
@Test
public void shouldNormalizeSwaggerBasePaths() {
final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation()));
assertThat(ProjectGeneratorHelper.normalizePaths(swagger).getPaths()).containsOnlyKeys("/path");
assertThat(ProjectGeneratorHelper.normalizePaths(swagger.basePath("/api")).getPaths()).containsOnlyKeys("/api/path");
}
}
代码示例来源:origin: io.syndesis.server/server-api-generator
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription,
final String expectedName, final String expectedDescription) {
operation = new Operation().description(operationDescription).summary(operationSummary);
swagger = new Swagger().path("/test", new Path().get(operation));
expected = new OperationDescription(expectedName, expectedDescription);
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription,
final String expectedName, final String expectedDescription) {
operation = new Operation().description(operationDescription).summary(operationSummary);
swagger = new Swagger().path("/test", new Path().get(operation));
expected = new OperationDescription(expectedName, expectedDescription);
}
内容来源于网络,如有侵权,请联系作者删除!