use of io.apicurio.datamodels.openapi.models.OasPathItem in project syndesis by syndesisio.
the class OpenApiGenerator method determineSummaryFrom.
private static ActionsSummary determineSummaryFrom(final List<OasPathItem> paths) {
if (paths == null || paths.isEmpty()) {
return new ActionsSummary.Builder().build();
}
final AtomicInteger total = new AtomicInteger(0);
final Map<String, Integer> tagCounts = //
paths.stream().flatMap(//
p -> OasModelHelper.getOperationMap(p).values().stream()).peek(//
o -> total.incrementAndGet()).flatMap(//
o -> OasModelHelper.sanitizeTags(o.tags)).collect(//
Collectors.groupingBy(//
Function.identity(), //
Collectors.reducing(0, (e) -> 1, Integer::sum)));
return //
new ActionsSummary.Builder().totalActions(//
total.intValue()).actionCountByTags(//
tagCounts).build();
}
use of io.apicurio.datamodels.openapi.models.OasPathItem in project syndesis by syndesisio.
the class Oas30DataShapeGeneratorHelper method getOperationParameters.
static List<Oas30Parameter> getOperationParameters(Oas30Document openApiDoc, Oas30Operation operation) {
final List<Oas30Parameter> operationParameters = getParameters(openApiDoc, operation);
OasPathItem parent = ofNullable(operation.parent()).filter(OasPathItem.class::isInstance).map(OasPathItem.class::cast).orElse(null);
final List<Oas30Parameter> pathParameters = getParameters(openApiDoc, parent);
operationParameters.addAll(pathParameters);
return operationParameters.stream().distinct().collect(Collectors.toList());
}
use of io.apicurio.datamodels.openapi.models.OasPathItem in project syndesis by syndesisio.
the class Oas20DataShapeGeneratorHelper method getOperationParameters.
static List<Oas20Parameter> getOperationParameters(Oas20Document openApiDoc, Oas20Operation operation) {
final List<Oas20Parameter> operationParameters = Oas20ModelHelper.getParameters(operation);
OasPathItem parent = ofNullable(operation.parent()).filter(OasPathItem.class::isInstance).map(OasPathItem.class::cast).orElse(null);
final List<Oas20Parameter> pathParameters = Oas20ModelHelper.getParameters(parent);
operationParameters.addAll(pathParameters);
final List<Oas20ParameterDefinition> globalParameters = ofNullable(openApiDoc.parameters).map(Oas20ParameterDefinitions::getItems).orElse(Collections.emptyList());
operationParameters.addAll(globalParameters);
return operationParameters;
}
use of io.apicurio.datamodels.openapi.models.OasPathItem in project syndesis by syndesisio.
the class Oas30ValidationRules method validateUnsupportedLinksFeature.
/**
* OpenAPI 3.x adds links feature which is not supported at the moment. Add warning when links are specified
* either as component or in an individual response object as all links will be ignored.
* @param info the info holding the OpenAPI document.
* @return info with maybe a warning added due to the unsupported feature.
*/
static OpenApiModelInfo validateUnsupportedLinksFeature(OpenApiModelInfo info) {
if (info.getModel() == null) {
return info;
}
final Oas30Document openApiDoc = info.getV3Model();
final OpenApiModelInfo.Builder withWarnings = new OpenApiModelInfo.Builder().createFrom(info);
if (openApiDoc.components != null && openApiDoc.components.links != null && !openApiDoc.components.links.isEmpty()) {
withWarnings.addWarning(new Violation.Builder().error("unsupported-links-feature").message("Links component is not supported yet. This part of the OpenAPI specification will be ignored.").build());
}
final List<OasPathItem> paths = OasModelHelper.getPathItems(info.getModel().paths);
for (final OasPathItem pathEntry : paths) {
for (final Map.Entry<String, OasOperation> operationEntry : OasModelHelper.getOperationMap(pathEntry).entrySet()) {
if (operationEntry.getValue().responses == null) {
continue;
}
// Check links usage on responses
List<Oas30Response> responses = operationEntry.getValue().responses.getResponses().stream().filter(Oas30Response.class::isInstance).map(Oas30Response.class::cast).collect(Collectors.toList());
for (final Oas30Response responseEntry : responses) {
if (responseEntry.links != null && !responseEntry.links.isEmpty()) {
final String message = "Operation " + operationEntry.getKey().toUpperCase(Locale.US) + " " + pathEntry.getPath() + " uses unsupported links feature. All links will be ignored.";
withWarnings.addWarning(//
new Violation.Builder().property(//
"").error(//
"unsupported-links-feature").message(//
message).build());
}
}
}
}
return withWarnings.build();
}
use of io.apicurio.datamodels.openapi.models.OasPathItem in project syndesis by syndesisio.
the class Oas30ValidationRules method validateUnsupportedCallbacksFeature.
/**
* OpenAPI 3.x adds callbacks feature which is not supported at the moment. Add warning when callbacks are specified
* either as component or in an individual operation as all callbacks will be ignored.
* @param info the info holding the OpenAPI document.
* @return info with maybe a warning added due to the unsupported feature.
*/
static OpenApiModelInfo validateUnsupportedCallbacksFeature(OpenApiModelInfo info) {
if (info.getModel() == null) {
return info;
}
final Oas30Document openApiDoc = info.getV3Model();
final OpenApiModelInfo.Builder withWarnings = new OpenApiModelInfo.Builder().createFrom(info);
if (openApiDoc.components != null && openApiDoc.components.callbacks != null && !openApiDoc.components.callbacks.isEmpty()) {
withWarnings.addWarning(new Violation.Builder().error("unsupported-callbacks-feature").message("Callbacks component is not supported yet. This part of the OpenAPI specification will be ignored.").build());
}
final List<OasPathItem> paths = OasModelHelper.getPathItems(info.getModel().paths);
for (final OasPathItem pathEntry : paths) {
for (final Map.Entry<String, Oas30Operation> operationEntry : Oas30ModelHelper.getOperationMap(pathEntry).entrySet()) {
// Check callback usage on operation
if (operationEntry.getValue().callbacks != null && !operationEntry.getValue().callbacks.isEmpty()) {
final String message = "Operation " + operationEntry.getKey().toUpperCase(Locale.US) + " " + pathEntry.getPath() + " uses unsupported callbacks feature. All callbacks will be ignored.";
withWarnings.addWarning(//
new Violation.Builder().property(//
"").error(//
"unsupported-callbacks-feature").message(//
message).build());
}
}
}
return withWarnings.build();
}
Aggregations