本文整理了Java中io.swagger.models.Path.getOperationMap()
方法的一些代码示例,展示了Path.getOperationMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.getOperationMap()
方法的具体详情如下:
包路径:io.swagger.models.Path
类名称:Path
方法名:getOperationMap
暂无
代码示例来源:origin: apache/servicecomb-java-chassis
private void convertOperations() {
Map<String, Path> paths = swagger.getPaths();
if (paths == null || paths.isEmpty()) {
return;
}
appendLine(serviceBuilder, "service MainService {");
for (Path path : paths.values()) {
for (Operation operation : path.getOperationMap().values()) {
convertOperation(operation);
}
}
serviceBuilder.setLength(serviceBuilder.length() - 1);
appendLine(serviceBuilder, "}");
}
代码示例来源: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: apache/servicecomb-java-chassis
String strPath = entry.getKey();
Path path = entry.getValue();
for (Entry<HttpMethod, Operation> operationEntry : path.getOperationMap().entrySet()) {
Operation operation = operationEntry.getValue();
if (operation.getOperationId() == null) {
代码示例来源:origin: yangfuhai/jboot
@Override
@JSONField(serialize = false)
public Map<HttpMethod, Operation> getOperationMap() {
return super.getOperationMap();
}
}
代码示例来源:origin: org.zalando/vertx-swagger
private Map<String, Parameter> getParameterMap(Path path) {
Map<HttpMethod, Operation> operationMap = path.getOperationMap();
return operationMap.get(HttpMethod.GET).getParameters().stream().collect(
Collectors.toMap(
Parameter::getName,
(Function<Parameter, Parameter>) param -> param));
}
代码示例来源:origin: io.syndesis.rest/rest-connector-generator
public static OperationDescription operationDescriptionOf(final Swagger swagger, final Operation operation) {
final Entry<String, Path> pathEntry = swagger.getPaths().entrySet().stream()
.filter(e -> e.getValue().getOperations().contains(operation)).findFirst().get();
final String path = pathEntry.getKey();
final Entry<HttpMethod, Operation> operationEntry = pathEntry.getValue().getOperationMap().entrySet().stream()
.filter(e -> e.getValue().equals(operation)).findFirst().get();
final HttpMethod method = operationEntry.getKey();
final String specifiedSummary = trimToNull(operation.getSummary());
final String specifiedDescription = trimToNull(operation.getDescription());
final String name = ofNullable(specifiedSummary).orElseGet(() -> method + " " + path);
final String description = ofNullable(specifiedDescription).orElseGet(() -> "Send " + method + " request to " + path);
return new OperationDescription(name, description);
}
代码示例来源:origin: phiz71/vertx-swagger
private void manageOperationNames(Path path, String pathname) {
String serviceIdTemp;
Map<HttpMethod, Operation> operationMap = path.getOperationMap();
if (operationMap != null) {
for (Entry<HttpMethod, Operation> entry : operationMap.entrySet()) {
serviceIdTemp = computeServiceId(pathname, entry);
entry.getValue().setVendorExtension("x-serviceId", serviceIdTemp);
entry.getValue().setVendorExtension("x-serviceId-varName", serviceIdTemp.toUpperCase() + "_SERVICE_ID");
}
}
}
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core
private boolean isPathNotExist(Map<String, UriTemplate> uriTemplateMap, String securityName, Map.Entry<String,
Path> entry) {
Path path = entry.getValue();
String uri = entry.getKey();
path.getOperationMap().entrySet().forEach(httpMethodOperationEntry -> {
if (isOperationNotExist(httpMethodOperationEntry, uri, uriTemplateMap, securityName)) {
path.set(httpMethodOperationEntry.getKey().name().toLowerCase(), null);
}
});
return path.isEmpty();
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
public static OperationDescription operationDescriptionOf(final Swagger swagger, final Operation operation) {
final Entry<String, Path> pathEntry = swagger.getPaths().entrySet().stream()
.filter(e -> e.getValue().getOperations().contains(operation)).findFirst().get();
final String path = pathEntry.getKey();
final Entry<HttpMethod, Operation> operationEntry = pathEntry.getValue().getOperationMap().entrySet().stream()
.filter(e -> e.getValue().equals(operation)).findFirst().get();
final HttpMethod method = operationEntry.getKey();
final String specifiedSummary = trimToNull(operation.getSummary());
final String specifiedDescription = trimToNull(operation.getDescription());
final String name = ofNullable(toLiteralNull(specifiedSummary)).orElseGet(() -> method + " " + path);
final String description = ofNullable(toLiteralNull(specifiedDescription))
.orElseGet(() -> "Send " + method + " request to " + path);
return new OperationDescription(name, description);
}
代码示例来源:origin: wso2/carbon-apimgt
private boolean isPathNotExist(Map<String, UriTemplate> uriTemplateMap, String securityName, Map.Entry<String,
Path> entry) {
Path path = entry.getValue();
String uri = entry.getKey();
path.getOperationMap().entrySet().forEach(httpMethodOperationEntry -> {
if (isOperationNotExist(httpMethodOperationEntry, uri, uriTemplateMap, securityName)) {
path.set(httpMethodOperationEntry.getKey().name().toLowerCase(), null);
}
});
return path.isEmpty();
}
代码示例来源:origin: io.syndesis.server/server-api-generator
public static OperationDescription operationDescriptionOf(final Swagger swagger, final Operation operation, final BiFunction<String, String, String> consumer) {
final Entry<String, Path> pathEntry = swagger.getPaths().entrySet().stream()
.filter(e -> e.getValue().getOperations().contains(operation)).findFirst().get();
final String path = pathEntry.getKey();
final Entry<HttpMethod, Operation> operationEntry = pathEntry.getValue().getOperationMap().entrySet().stream()
.filter(e -> e.getValue().equals(operation)).findFirst().get();
final HttpMethod method = operationEntry.getKey();
final String specifiedSummary = trimToNull(operation.getSummary());
final String specifiedDescription = trimToNull(operation.getDescription());
final String name = ofNullable(toLiteralNull(specifiedSummary)).orElseGet(() -> method + " " + path);
final String description = ofNullable(toLiteralNull(specifiedDescription))
.orElseGet(() -> consumer.apply(method.name(), path));
return new OperationDescription(name, description);
}
代码示例来源:origin: org.apache.servicecomb/common-protobuf
private void convertOperations() {
Map<String, Path> paths = swagger.getPaths();
if (paths == null || paths.isEmpty()) {
return;
}
appendLine(serviceBuilder, "service MainService {");
for (Path path : paths.values()) {
for (Operation operation : path.getOperationMap().values()) {
convertOpeation(operation);
}
}
serviceBuilder.setLength(serviceBuilder.length() - 1);
appendLine(serviceBuilder, "}");
}
代码示例来源:origin: Sayi/swagger-diff
private static List<Endpoint> convert2EndpointList(Map<String, Path> map) {
List<Endpoint> endpoints = new ArrayList<Endpoint>();
if (null == map) return endpoints;
map.forEach((url, path) -> {
Map<HttpMethod, Operation> operationMap = path.getOperationMap();
operationMap.forEach((httpMethod, operation) -> {
Endpoint endpoint = new Endpoint();
endpoint.setPathUrl(url);
endpoint.setMethod(httpMethod);
endpoint.setSummary(operation.getSummary());
endpoint.setPath(path);
endpoint.setOperation(operation);
endpoints.add(endpoint);
});
});
return endpoints;
}
代码示例来源:origin: outofcoffee/imposter
/**
* Bind a handler to each operation.
*
* @param router the Vert.x router
* @param config the plugin configuration
* @param swagger the OpenAPI specification
* @param path the mock path
* @param pathConfig the path configuration
*/
private void handlePathOperations(Router router, OpenApiPluginConfig config, Swagger swagger, String path, Path pathConfig) {
pathConfig.getOperationMap().forEach((httpMethod, operation) -> {
final String fullPath = ofNullable(swagger.getBasePath()).orElse("") + convertPath(path);
LOGGER.debug("Adding mock endpoint: {} -> {}", httpMethod, fullPath);
// convert an {@link io.swagger.models.HttpMethod} to an {@link io.vertx.core.http.HttpMethod}
final HttpMethod method = HttpMethod.valueOf(httpMethod.name());
router.route(method, fullPath).handler(buildHandler(config, swagger, operation));
});
}
代码示例来源:origin: io.syndesis.server/server-api-generator
static SwaggerModelInfo validateNoMissingOperationIds(final SwaggerModelInfo info) {
final Swagger swagger = info.getModel();
if (swagger == null) {
return info;
}
long countNoOpId = swagger.getPaths().values().stream()
.flatMap(p -> p.getOperationMap().values().stream())
.filter(o -> o.getOperationId() == null)
.count();
if (countNoOpId == 0) {
return info;
}
final SwaggerModelInfo.Builder withWarnings = new SwaggerModelInfo.Builder().createFrom(info);
withWarnings.addWarning(new Violation.Builder()//
.error("missing-operation-ids")
.message("Some operations (" + countNoOpId + ") have no operationId").build());
return withWarnings.build();
}
代码示例来源:origin: org.zalando/vertx-swagger
public DefaultBindingBuilder(BindingBuilderFactory bindingBuilderFactory, SwaggerRouter swaggerRouter, String path) {
this.bindingBuilderFactory = bindingBuilderFactory;
this.swaggerRouter = swaggerRouter;
this.routeConfiguration = new RouteConfiguration(path);
Path swaggerPath = swaggerRouter.getSwagger().getPath(routeConfiguration.getSwaggerPath());
Preconditions.checkNotNull(swaggerPath, String.format("Could not find swagger path: [%s] in swagger spec: [%s]", routeConfiguration.getSwaggerPath(), swaggerRouter.getSwagger().getPaths().keySet()));
this.operationMap = swaggerPath.getOperationMap();
}
代码示例来源:origin: phiz71/vertx-swagger
public static Router swaggerRouter(Router baseRouter, Swagger swagger, EventBus eventBus, ServiceIdResolver serviceIdResolver, Function<RoutingContext, DeliveryOptions> configureMessage) {
baseRouter.route().handler(BodyHandler.create());
final String basePath = getBasePath(swagger);
SwaggerAuthHandlerFactory authHandlerFactory = getSwaggerAuthHandlerFactory(swagger);
swagger.getPaths().forEach((path, pathDescription) -> pathDescription.getOperationMap().forEach((method, operation) -> {
String convertedPath = convertParametersToVertx(basePath + path);
configureAuthRoute(baseRouter, method, convertedPath, swagger, operation, authHandlerFactory);
Route route = ROUTE_BUILDERS.get(method).buildRoute(baseRouter, convertedPath);
String serviceId = serviceIdResolver.resolve(method, path, operation);
configureRoute(route, serviceId, operation, eventBus, configureMessage);
}));
return baseRouter;
}
代码示例来源:origin: io.syndesis.server/server-api-generator
@Test
public void shouldGenerateAtlasmapSchemaSetForUpdatePetRequest() throws IOException {
final Operation swaggerOperation = swagger.getPaths().get(path).getOperationMap().get(operation);
final DataShape shape = generator.createShapeFromRequest(json, swagger, swaggerOperation);
final SoftAssertions softly = new SoftAssertions();
softly.assertThat(shape.getKind()).isEqualTo(DataShapeKinds.XML_SCHEMA);
softly.assertThat(shape.getName()).isEqualTo("Request");
softly.assertThat(shape.getDescription()).isEqualTo("API request payload");
softly.assertThat(shape.getExemplar()).isNotPresent();
softly.assertAll();
final String expectedSpecification;
try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream("/swagger/" + schemaset)) {
expectedSpecification = IOUtils.toString(in, StandardCharsets.UTF_8);
}
final String specification = shape.getSpecification();
assertThat(specification).isXmlEqualTo(expectedSpecification);
}
代码示例来源:origin: io.syndesis.rest/rest-connector-generator
@Test
public void shouldGenerateAtlasmapSchemaSetForUpdatePetRequest() throws IOException {
final Operation swaggerOperation = swagger.getPaths().get(path).getOperationMap().get(operation);
final DataShape shape = generator.createShapeFromRequest(swaggerSpecification, swagger, swaggerOperation);
final SoftAssertions softly = new SoftAssertions();
softly.assertThat(shape.getKind()).isEqualTo(DataShapeKinds.XML_SCHEMA);
softly.assertThat(shape.getName()).isEqualTo("Request");
softly.assertThat(shape.getDescription()).isEqualTo("API request payload");
softly.assertThat(shape.getExemplar()).isNotPresent();
softly.assertAll();
final String expectedSpecification;
try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream("/swagger/" + schemaset)) {
expectedSpecification = IOUtils.toString(in, StandardCharsets.UTF_8);
}
final String specification = shape.getSpecification();
assertThat(specification).isXmlEqualTo(expectedSpecification);
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldGenerateAtlasmapSchemaSetForUpdatePetRequest() throws IOException {
final Operation swaggerOperation = swagger.getPaths().get(path).getOperationMap().get(operation);
final DataShape shape = generator.createShapeFromRequest(json, swagger, swaggerOperation);
final SoftAssertions softly = new SoftAssertions();
softly.assertThat(shape.getKind()).isEqualTo(DataShapeKinds.XML_SCHEMA);
softly.assertThat(shape.getName()).isEqualTo("Request");
softly.assertThat(shape.getDescription()).isEqualTo("API request payload");
softly.assertThat(shape.getExemplar()).isNotPresent();
softly.assertAll();
final String expectedSpecification;
try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream("/swagger/" + schemaset)) {
expectedSpecification = IOUtils.toString(in, StandardCharsets.UTF_8);
}
final String specification = shape.getSpecification();
assertThat(specification).isXmlEqualTo(expectedSpecification);
}
内容来源于网络,如有侵权,请联系作者删除!