use of io.syndesis.server.connector.generator.swagger.util.OperationDescription in project syndesis by syndesisio.
the class BaseSwaggerConnectorGenerator method configureConnector.
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(), swagger, operation).camelConnectorGAV(//
connectorGav).camelConnectorPrefix(//
connectorScheme).connectorId(//
connectorId).build();
final OperationDescription description = SwaggerHelper.operationDescriptionOf(swagger, operation);
final ConnectorAction action = //
new ConnectorAction.Builder().id(//
createActionId(connectorId, connectorGav, operation)).name(//
description.name).description(//
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();
}
Aggregations