io.swagger.models.Path.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中io.swagger.models.Path.<init>()方法的一些代码示例,展示了Path.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.<init>()方法的具体详情如下:
包路径:io.swagger.models.Path
类名称:Path
方法名:<init>

Path.<init>介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

Optional.ofNullable(swagger.getPath(pattern))
  .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: 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: com.haulmont.cuba/cuba-rest-api

protected Map<String, Path> generateEntityFilterPaths(ModelImpl entityModel) {
  return Collections.singletonMap(
      String.format(ENTITY_SEARCH, entityModel.getName()),
      new Path()
          .get(generateEntitySearchOperation(entityModel, RequestMethod.GET))
          .post(generateEntitySearchOperation(entityModel, RequestMethod.POST)));
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

protected Map<String, Path> generateEntityPath(ModelImpl entityModel) {
  return Collections.singletonMap(
      String.format(ENTITY_PATH, entityModel.getName()),
      new Path()
          .get(generateEntityBrowseOperation(entityModel))
          .post(generateEntityCreateOperation(entityModel)));
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

protected Map<String, Path> generateEntityRUDPaths(ModelImpl entityModel) {
  return Collections.singletonMap(
      String.format(ENTITY_RUD_OPS, entityModel.getName()),
      new Path()
          .get(generateEntityReadOperation(entityModel))
          .put(generateEntityUpdateOperation(entityModel))
          .delete(generateEntityDeleteOperation(entityModel)));
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

protected Path generateServiceMethodPath(String service, RestMethodInfo methodInfo) {
  return new Path()
      .get(generateServiceMethodOp(service, methodInfo, RequestMethod.GET))
      .post(generateServiceMethodOp(service, methodInfo, RequestMethod.POST));
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private Path path2Factory(ServiceDocument doc) {
  Path path = new Path();
  path.setPost(opCreateInstance(doc));
  path.setGet(opFactoryGetInstances());
  return path;
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

protected Path generateQueryPath(RestQueriesConfiguration.QueryInfo query) {
  return new Path()
      .get(generateQueryOperation(query, RequestMethod.GET))
      .post(generateQueryOperation(query, RequestMethod.POST));
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

protected Path generateQueryCountPath(RestQueriesConfiguration.QueryInfo query) {
  return new Path()
      .get(generateQueryCountOperation(query, RequestMethod.GET))
      .post(generateQueryCountOperation(query, RequestMethod.POST));
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private Path path2UtilTemplate(Parameter idParam) {
  Path path = new Path();
  if (idParam != null) {
    path.setParameters(Collections.singletonList(paramId()));
    path.setGet(opDefault(template(ServiceDocument.class)));
  } else {
    // idParam == null -> it is a factory
    path.setGet(opDefault(template(ServiceDocumentQueryResult.class)));
  }
  return 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: com.vmware.xenon/xenon-swagger

private Path path2UtilSubscriptions(Parameter idParam) {
  Path path = new Path();
  if (idParam != null) {
    path.setParameters(Collections.singletonList(paramId()));
  }
  ServiceDocument subscriptionState = template(ServiceSubscriptionState.class);
  path.setGet(opDefault(subscriptionState));
  io.swagger.models.Operation deleteOrPost = new io.swagger.models.Operation();
  deleteOrPost.addParameter(paramBody(template(ServiceSubscriber.class)));
  deleteOrPost.addTag(this.currentTag.getName());
  deleteOrPost.setResponses(responseMap(
      Operation.STATUS_CODE_OK, responseOk(subscriptionState)
  ));
  path.setDelete(deleteOrPost);
  path.setPost(deleteOrPost);
  return 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.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.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-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);
}

相关文章