当前位置: 首页>>代码示例>>Java>>正文


Java Swagger.getPaths方法代码示例

本文整理汇总了Java中io.swagger.models.Swagger.getPaths方法的典型用法代码示例。如果您正苦于以下问题:Java Swagger.getPaths方法的具体用法?Java Swagger.getPaths怎么用?Java Swagger.getPaths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.swagger.models.Swagger的用法示例。


在下文中一共展示了Swagger.getPaths方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import io.swagger.models.Swagger; //导入方法依赖的package包/类
@Before
public void setup() {
  BeanUtils.setContext(applicationContext);

  MicroserviceMeta mm = new MicroserviceMeta("app:ms");
  Swagger swagger = UnitTestSwaggerUtils.generateSwagger(TestServicePathManagerSchemaImpl.class).getSwagger();
  Map<String, Path> paths = swagger.getPaths();

  swagger.setBasePath("");
  Path path = paths.remove("/static1");
  paths.put("/root/rest/static1", path);

  path = paths.remove("/dynamic1");
  paths.put("/dynamic1/{id}", path);

  path = paths.remove("/dynamic2");
  paths.put("/dynamic2/{id}", path);

  SchemaMeta schemaMeta = new SchemaMeta(swagger, mm, "sid");

  spm = new ServicePathManager(mm);
  spm.addSchema(schemaMeta);
  spm.sortPath();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:25,代码来源:TestServicePathManager.java

示例2: mergePathDefinitions

import io.swagger.models.Swagger; //导入方法依赖的package包/类
public Map<String, Path> mergePathDefinitions(Swagger target, Swagger source) {
	LinkedHashMap<String, Path> mergedDefinitions = new LinkedHashMap<>();
	mergedDefinitions.putAll(target.getPaths());

	Map<String, Path> pathsToBeMerged = source.getPaths();

	for (Entry<String, Path> entry : pathsToBeMerged.entrySet()) {
		if (!mergedDefinitions.containsKey(entry.getKey())) {
			logger.info("source path %s is not present in existing Swagger JSON file.", entry.getKey());
			mergedDefinitions.put(entry.getKey(), entry.getValue());
		} else {
			
			logger.info("source path %s is present in existing Swagger JSON file...merging operations", entry.getKey());
			
			Map<HttpMethod, Operation> modifedOperations = mergeOperationPaths(mergedDefinitions.get(entry.getKey()),
					entry.getValue());
			
			for(Entry<HttpMethod, Operation> operation : modifedOperations.entrySet()){
				mergedDefinitions.get(entry.getKey()).set(operation.getKey().name().toLowerCase(), operation.getValue());
			}				
		}
	}

	return mergedDefinitions;

}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:27,代码来源:SwaggerUpdater.java

示例3: correctResponses

import io.swagger.models.Swagger; //导入方法依赖的package包/类
public static void correctResponses(Swagger swagger) {
  if (swagger.getPaths() == null) {
    return;
  }

  for (Path path : swagger.getPaths().values()) {
    for (Operation operation : path.getOperations()) {
      correctResponses(operation);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:SwaggerUtils.java

示例4: processPaths

import io.swagger.models.Swagger; //导入方法依赖的package包/类
private void processPaths(final Map<String, Path> swagger,
    final Map<String, Model> definitionsMap,
    final Map<String, SecuritySchemeDefinition> securityDefinitionsMap,
    final Swagger remoteSwagger,
    final int i,
    final int j) {

    int k = 0;
    while (env.containsProperty(String.format("swagger[%d].uris[%d].paths[%d].from", i, j, k)) || env.containsProperty(String.format("swagger[%d].uris[%d].paths[%d]", i, j, k))) {
        if (env.containsProperty(String.format("swagger[%d].uris[%d].paths[%d].from", i, j, k))) {
            final String from = env.getRequiredProperty(String.format("swagger[%d].uris[%d].paths[%d].from", i, j, k));
            final String to = env.getRequiredProperty(String.format("swagger[%d].uris[%d].paths[%d].to", i, j, k));

            LOG.debug("getting path={} from paths={} and transform to={}", from, remoteSwagger.getPaths().keySet(), to);
            Optional.ofNullable(remoteSwagger.getPaths())
                .ifPresent(t -> remoteSwagger.getPaths().keySet().parallelStream()
                    .filter(s -> s.startsWith(from))
                    .forEach(p -> swagger.put(to + p.substring(from.length()), remoteSwagger.getPath(p))));

            updateDefinitions(definitionsMap, securityDefinitionsMap, remoteSwagger);
        } else {
            final String path = env.getRequiredProperty(String.format("swagger[%d].uris[%d].paths[%d]", i, j, k));
            if (LOG.isDebugEnabled()) {
                LOG.debug("getting path={} from paths={}", path, remoteSwagger.getPaths().keySet());
            }
            if (remoteSwagger.getPaths() != null) {
                remoteSwagger.getPaths().keySet().parallelStream()
                    .filter(s -> s.startsWith(path))
                    .forEach(p -> swagger.put(p, remoteSwagger.getPath(p)));
            }
            updateDefinitions(definitionsMap, securityDefinitionsMap, remoteSwagger);
        }
        ++k;
    }
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:36,代码来源:SwaggerCollator.java

示例5: toParsedPaths

import io.swagger.models.Swagger; //导入方法依赖的package包/类
public static List<ParsedPath> toParsedPaths(Swagger swagger) {
    List<ParsedPath> parsedPaths = new ArrayList<>();
    if (swagger.getPaths() != null) {
        swagger.getPaths().forEach((pathTemplate, path) -> parsedPaths.add(new ParsedPath(pathTemplate, path)));
    }
    return parsedPaths;
}
 
开发者ID:Cosium,项目名称:openapi-annotation-processor,代码行数:8,代码来源:SwaggerUtils.java

示例6: configureConnector

import io.swagger.models.Swagger; //导入方法依赖的package包/类
protected final Connector configureConnector(final ConnectorTemplate connectorTemplate, final Connector connector,
    final ConnectorSettings connectorSettings) {

    final Connector.Builder builder = new Connector.Builder().createFrom(connector);

    final SwaggerModelInfo info = parseSpecification(connectorSettings, false);
    final Swagger swagger = info.getModel();
    addGlobalParameters(builder, swagger);

    final Map<String, Path> paths = swagger.getPaths();

    final String connectorId = connector.getId().get();
    final String connectorGav = connectorTemplate.getCamelConnectorGAV();
    final String connectorScheme = connectorTemplate.getCamelConnectorPrefix();

    final List<ConnectorAction> actions = new ArrayList<>();
    int idx = 0;
    for (final Entry<String, Path> pathEntry : paths.entrySet()) {
        final Path path = pathEntry.getValue();

        final Map<HttpMethod, Operation> operationMap = path.getOperationMap();

        for (final Entry<HttpMethod, Operation> entry : operationMap.entrySet()) {
            final Operation operation = entry.getValue();
            if (operation.getOperationId() == null) {
                operation.operationId("operation-" + idx++);
            }

            final ConnectorDescriptor descriptor = createDescriptor(info.getResolvedSpecification(), operation)//
                .camelConnectorGAV(connectorGav)//
                .camelConnectorPrefix(connectorScheme)//
                .connectorId(connectorId)//
                .build();

            final String summary = trimToNull(operation.getSummary());
            final String specifiedDescription = trimToNull(operation.getDescription());

            final String name;
            final String description;
            if (summary == null && specifiedDescription == null) {
                name = entry.getKey() + " " + pathEntry.getKey();
                description = null;
            } else if (specifiedDescription == null) {
                name = entry.getKey() + " " + pathEntry.getKey();
                description = summary;
            } else {
                name = summary;
                description = specifiedDescription;
            }

            final ConnectorAction action = new ConnectorAction.Builder()//
                .id(createActionId(connectorId, connectorGav, operation))//
                .name(name)//
                .description(description)//
                .pattern(Action.Pattern.To)//
                .descriptor(descriptor).tags(ofNullable(operation.getTags()).orElse(Collections.emptyList()))//
                .build();

            actions.add(action);
        }
    }

    actions.sort(ActionComparator.INSTANCE);
    builder.addAllActions(actions);

    builder.putConfiguredProperty("specification", SwaggerHelper.serialize(swagger));

    return builder.build();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:70,代码来源:BaseSwaggerConnectorGenerator.java


注:本文中的io.swagger.models.Swagger.getPaths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。