當前位置: 首頁>>代碼示例>>Java>>正文


Java Operation.getParameters方法代碼示例

本文整理匯總了Java中io.swagger.models.Operation.getParameters方法的典型用法代碼示例。如果您正苦於以下問題:Java Operation.getParameters方法的具體用法?Java Operation.getParameters怎麽用?Java Operation.getParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.swagger.models.Operation的用法示例。


在下文中一共展示了Operation.getParameters方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testApplyParameters

import io.swagger.models.Operation; //導入方法依賴的package包/類
@SuppressWarnings({  "serial" })
	@Test
	public void testApplyParameters(){
		Swagger swagger = new Swagger();
		Reader.read(swagger, new HashMap<Class<?>, Object>(){{
			put(InterfaceServiceTest.class, new InterfaceServiceImplTest());
		}}, "/h");
		
//		System.out.println(Json.pretty(swagger));
		
		Path path = swagger.getPaths().get("/h/com.deepoove.swagger.dubbo.api.InterfaceServiceTest/test");
		Assert.assertNotNull(path);
		Operation operation = path.getOperationMap().get(HttpMethod.POST);
		Assert.assertNotNull(operation);
		Assert.assertNotNull(operation.getParameters());
		
		List<Parameter> parameters = operation.getParameters();
		Assert.assertTrue(parameters.get(0).getName().equals("para"));
		Assert.assertTrue(parameters.get(1).getName().equals("code"));
		
	}
 
開發者ID:Sayi,項目名稱:swagger-dubbo,代碼行數:22,代碼來源:ReaderTest.java

示例2: findSwaggerParameter

import io.swagger.models.Operation; //導入方法依賴的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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:12,代碼來源:SwaggerGenerator.java

示例3: 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);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:39,代碼來源:ClassUtils.java

示例4: getParameters

import io.swagger.models.Operation; //導入方法依賴的package包/類
public Collection<Parameter> getParameters() {
    Operation op = getOperation();
    if (op != null) {
        return op.getParameters();
    }
    return new ArrayList<>();
}
 
開發者ID:limberest,項目名稱:limberest,代碼行數:8,代碼來源:SwaggerRequest.java

示例5: createDescriptor

import io.swagger.models.Operation; //導入方法依賴的package包/類
@Override
ConnectorDescriptor.Builder createDescriptor(final String specification, final Operation operation) {
    final ConnectorDescriptor.Builder actionDescriptor = new ConnectorDescriptor.Builder();

    final List<Parameter> parameters = operation.getParameters();
    final Optional<BodyParameter> maybeRequestBody = parameters.stream()
        .filter(p -> p instanceof BodyParameter && ((BodyParameter) p).getSchema() != null).map(BodyParameter.class::cast).findFirst();
    final DataShape inputDataShape = maybeRequestBody.map(requestBody -> createShapeFromModel(specification, requestBody.getSchema()))
        .orElse(DATA_SHAPE_NONE);
    actionDescriptor.inputDataShape(inputDataShape);

    final ActionDescriptor.ActionDescriptorStep.Builder stepBuilder = new ActionDescriptor.ActionDescriptorStep.Builder()
        .name("Query parameters").description("Specify query parameters");

    for (final Parameter parameter : parameters) {
        final Optional<ConfigurationProperty> property = createPropertyFromParameter(parameter);

        if (property.isPresent()) {
            stepBuilder.putProperty(parameter.getName(), property.get());
        }
    }

    final Optional<Response> maybeResponse = operation.getResponses().values().stream().filter(r -> r.getSchema() != null).findFirst();
    final DataShape outputDataShape = maybeResponse.map(response -> createShapeFromResponse(specification, response))
        .orElse(DATA_SHAPE_NONE);
    actionDescriptor.outputDataShape(outputDataShape);

    actionDescriptor.putConfiguredProperty("operationId", operation.getOperationId());

    final ActionDescriptorStep step = stepBuilder.build();
    if (!step.getProperties().isEmpty()) {
        actionDescriptor.addPropertyDefinitionStep(step);
    }

    return actionDescriptor;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:37,代碼來源:SwaggerActionParamsConnectorGenerator.java

示例6: map

import io.swagger.models.Operation; //導入方法依賴的package包/類
Map<String, String> map(@NonNull Operation operation, @NonNull InformationProduct product,
    @NonNull RequestParameters requestParameters) {
  Map<String, String> result = new HashMap<>();

  for (io.swagger.models.parameters.Parameter openApiParameter : operation.getParameters()) {
    Map<String, Object> vendorExtensions = openApiParameter.getVendorExtensions();

    LOG.debug("Vendor extensions for parameter '{}': {}", openApiParameter.getName(),
        vendorExtensions);

    Object parameterIdString = vendorExtensions.get(OpenApiSpecificationExtensions.PARAMETER);

    if (parameterIdString == null) {
      // Vendor extension x-dotwebstack-parameter not found for parameter
      continue;
    }

    IRI parameterId = VALUE_FACTORY.createIRI((String) parameterIdString);
    Parameter<?> parameter = getParameter(product, parameterId);

    if (parameter == null) {
      throw new ConfigurationException(String.format(
          "No parameter found for vendor extension value: '%s'", parameterIdString));
    }

    String value = (String) requestParameters.get(openApiParameter.getName());

    result.put(parameter.getName(), value);
  }

  return result;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:33,代碼來源:RequestParameterMapper.java


注:本文中的io.swagger.models.Operation.getParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。