本文整理匯總了Java中io.swagger.models.Path.getOperations方法的典型用法代碼示例。如果您正苦於以下問題:Java Path.getOperations方法的具體用法?Java Path.getOperations怎麽用?Java Path.getOperations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.swagger.models.Path
的用法示例。
在下文中一共展示了Path.getOperations方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateOperationIdList
import io.swagger.models.Path; //導入方法依賴的package包/類
/**
* @param swagger
* @return
*/
private List<String> generateOperationIdList(Swagger swagger) {
// Iterate through Paths,then operations in the Swagger file
Map<String, Path> pathMap = swagger.getPaths();
List<String> operationIdList = new ArrayList<>();
for (Map.Entry<String, Path> pathDetail : pathMap.entrySet()) {
Path path = pathDetail.getValue();
List<Operation> operationList = path.getOperations();
for (Operation operation : operationList) {
operationIdList.add(operation.getOperationId());
}
}
return operationIdList;
}
示例2: test_3
import io.swagger.models.Path; //導入方法依賴的package包/類
@Test
public void test_3() throws Exception
{
Swagger swagger = new Swagger();
String restJavaPackage = "org.finra.herd.swaggergen.test.restControllerProcessor.case3";
String tagPatternTemplate = "(?<tag>.+?)RestController";
Class<?> modelErrorClass = null;
new RestControllerProcessor(LOG, swagger, restJavaPackage, tagPatternTemplate, modelErrorClass);
List<String> operationIds = new ArrayList<>();
for (Path path : swagger.getPaths().values())
{
for (Operation operation : path.getOperations())
{
operationIds.add(operation.getOperationId());
}
}
assertEquals(2, operationIds.size());
assertTrue(operationIds.contains("Test3.duplicate"));
assertTrue(operationIds.contains("Test3.duplicate1"));
}
示例3: findSwaggerParameter
import io.swagger.models.Path; //導入方法依賴的package包/類
public List<Parameter> findSwaggerParameter(String methodName) {
for (Path path : swagger.getPaths().values()) {
for (Operation operation : path.getOperations()) {
if (methodName.equals(operation.getOperationId())) {
return operation.getParameters();
}
}
}
throw new Error("method not found, name=" + methodName);
}
示例4: createInterface
import io.swagger.models.Path; //導入方法依賴的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);
}
示例5: correctResponses
import io.swagger.models.Path; //導入方法依賴的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);
}
}
}
示例6: addFromSwagger
import io.swagger.models.Path; //導入方法依賴的package包/類
@Override
public void addFromSwagger(Service.Builder serviceBuilder, Swagger swagger) {
final Backend.Builder backendBuilder = serviceBuilder.getBackendBuilder();
for (final Map.Entry<String, Path> entry : swagger.getPaths().entrySet()) {
final Path path = entry.getValue();
for (final Operation operation : path.getOperations()) {
if (Strings.isNullOrEmpty(operation.getOperationId())) {
// Silently skip if the operation is invalid
continue;
}
final String selector =
namespacePrefix + NameConverter.operationIdToMethodName(operation.getOperationId());
final String backendUrl =
VendorExtensionUtils.getExtensionValueOrNull(
operation.getVendorExtensions(),
String.class,
this.diagCollector,
ExtensionNames.BACKEND_URL_EXTENSION);
final Integer backendDeadline =
VendorExtensionUtils.getExtensionValueOrNull(
operation.getVendorExtensions(),
Integer.class,
this.diagCollector,
ExtensionNames.BACKEND_DEADLINE_EXTENSION);
if (backendUrl != null) {
final BackendRule.Builder ruleBuilder = BackendRule.newBuilder()
.setSelector(selector)
.setAddress(backendUrl);
if (backendDeadline != null) {
ruleBuilder.setDeadline(backendDeadline);
}
backendBuilder.addRules(ruleBuilder);
}
}
}
if (backendBuilder.getRulesList().isEmpty()) {
serviceBuilder.clearBackend();
}
}