本文整理匯總了Java中io.swagger.models.Operation.getOperationId方法的典型用法代碼示例。如果您正苦於以下問題:Java Operation.getOperationId方法的具體用法?Java Operation.getOperationId怎麽用?Java Operation.getOperationId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.swagger.models.Operation
的用法示例。
在下文中一共展示了Operation.getOperationId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createInterface
import io.swagger.models.Operation; //導入方法依賴的package包/類
private static Class<?> createInterface(Swagger swagger, ClassLoader classLoader, String packageName,
String intfName) {
ClassConfig classConfig = new ClassConfig();
classConfig.setClassName(intfName);
classConfig.setIntf(true);
for (Path path : swagger.getPaths().values()) {
for (Operation operation : path.getOperations()) {
// 參數可能重名,所以packageName必須跟operation相關才能隔離
String opPackageName = packageName + "." + operation.getOperationId();
Response result = operation.getResponses().get(SwaggerConst.SUCCESS_KEY);
JavaType resultJavaType = ConverterMgr.findJavaType(classLoader,
opPackageName,
swagger,
result.getSchema());
MethodConfig methodConfig = new MethodConfig();
methodConfig.setName(operation.getOperationId());
methodConfig.setResult(resultJavaType);
for (Parameter parameter : operation.getParameters()) {
String paramName = parameter.getName();
paramName = correctMethodParameterName(paramName);
JavaType paramJavaType = ConverterMgr.findJavaType(classLoader,
opPackageName,
swagger,
parameter);
methodConfig.addParameter(paramName, paramJavaType);
}
classConfig.addMethod(methodConfig);
}
}
return JavassistUtils.createClass(classLoader, classConfig);
}
示例2: initOperations
import io.swagger.models.Operation; //導入方法依賴的package包/類
private void initOperations() {
for (Entry<String, Path> entry : swagger.getPaths().entrySet()) {
String strPath = entry.getKey();
Path path = entry.getValue();
for (Entry<HttpMethod, Operation> operationEntry : path.getOperationMap().entrySet()) {
Operation operation = operationEntry.getValue();
if (operation.getOperationId() == null) {
throw ExceptionUtils.operationIdInvalid(getSchemaId(), strPath);
}
// org.apache.servicecomb.swagger.engine.SwaggerEnvironment.createConsumer(Class<?>, Class<?>)
// org.apache.servicecomb.swagger.engine.SwaggerEnvironment.createProducer(Object, Swagger)
// had make sure that consumer/swagger or producer/swagger can work
//
// in this place, do not throw exception when method not exists
// eg:
// swagger interface is a.b.c, and consumer interface is a.b.c too.
// version 1, there are the same
// version 2, producer add a new operation, that means swagger have more operation than consumer interface a.b.c
// interface a.b.c in consumer process is the old interface
// so for swagger, can not do any valid check here
// only need to save found method, that's enough.
Method method = ReflectUtils.findMethod(swaggerIntf, operation.getOperationId());
if (method == null) {
LOGGER.warn("method {} not found in swagger interface {}, schemaId={}",
operation.getOperationId(),
swaggerIntf.getName(),
getSchemaId());
continue;
}
String httpMethod = operationEntry.getKey().name();
OperationMeta operationMeta = new OperationMeta();
operationMeta.init(this, method, strPath, httpMethod, operation);
operationMgr.register(method.getName(), operationMeta);
}
}
}
示例3: configureConnector
import io.swagger.models.Operation; //導入方法依賴的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();
}
示例4: createActionId
import io.swagger.models.Operation; //導入方法依賴的package包/類
static String createActionId(final String connectorId, final String connectorGav, final Operation operation) {
return connectorGav + ":" + connectorId + ":" + operation.getOperationId();
}