io.swagger.models.parameters.BodyParameter Java Examples

The following examples show how to use io.swagger.models.parameters.BodyParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BodyParameterExtractor.java    From vertx-swagger with Apache License 2.0 6 votes vote down vote up
@Override
public Object extract(String name, Parameter parameter, RoutingContext context) {
    BodyParameter bodyParam = (BodyParameter) parameter;
    if ("".equals(context.getBodyAsString())) {
        if (bodyParam.getRequired())
            throw new IllegalArgumentException("Missing required parameter: " + name);
        else
            return null;
    }

    try {
        if(bodyParam.getSchema() instanceof ArrayModel) {
            return context.getBodyAsJsonArray();
        } else {
            return context.getBodyAsJson();
        }
    } catch (DecodeException e) {
        return context.getBodyAsString();  
    }
}
 
Example #2
Source File: BodyProcessorCreator.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Override
public ParamValueProcessor create(Parameter parameter, Type genericParamType) {
  Model model = ((BodyParameter) parameter).getSchema();
  JavaType swaggerType = null;
  if (model instanceof ModelImpl) {
    swaggerType = ConverterMgr.findJavaType(((ModelImpl) model).getType(), ((ModelImpl) model).getFormat());
  }
  boolean isString = swaggerType != null && swaggerType.getRawClass().equals(String.class);

  JavaType targetType =
      genericParamType == null ? null : TypeFactory.defaultInstance().constructType(genericParamType);
  boolean rawJson = SwaggerUtils.isRawJsonType(parameter);
  if (rawJson) {
    return new RawJsonBodyProcessor(targetType, (String) parameter.getVendorExtensions()
        .get(SwaggerConst.EXT_JSON_VIEW), isString, parameter.getRequired());
  }

  return new BodyProcessor(targetType, (String) parameter.getVendorExtensions()
      .get(SwaggerConst.EXT_JSON_VIEW), isString, parameter.getRequired());
}
 
Example #3
Source File: RestOperationMeta.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
/**
 * EdgeService cannot recognize the map type form body whose value type is String,
 * so there should be this additional setting.
 * @param parameter the swagger information of the parameter
 * @param type the resolved param type
 * @return the corrected param type
 */
private Type correctFormBodyType(Parameter parameter, Type type) {
  if (null != type || !(parameter instanceof BodyParameter)) {
    return type;
  }
  final BodyParameter bodyParameter = (BodyParameter) parameter;
  if (!(bodyParameter.getSchema() instanceof ModelImpl)) {
    return type;
  }
  final Property additionalProperties = ((ModelImpl) bodyParameter.getSchema()).getAdditionalProperties();
  if (additionalProperties instanceof StringProperty) {
    type = RestObjectMapperFactory.getRestObjectMapper().getTypeFactory()
        .constructMapType(Map.class, String.class, String.class);
  }
  return type;
}
 
Example #4
Source File: SwaggerTypeAdapter.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
static SwaggerTypeAdapter create(Object swaggerType) {
  if (swaggerType instanceof SwaggerTypeAdapter) {
    return (SwaggerTypeAdapter) swaggerType;
  }

  if (swaggerType instanceof Model) {
    return new ModelAdapter((Model) swaggerType);
  }

  if (swaggerType instanceof Property) {
    return new PropertyAdapter((Property) swaggerType);
  }

  if (swaggerType instanceof SerializableParameter) {
    return new SerializableParameterAdapter((SerializableParameter) swaggerType);
  }

  if (swaggerType instanceof BodyParameter) {
    return new BodyParameterAdapter((BodyParameter) swaggerType);
  }

  throw new IllegalStateException("not support swagger type: " + swaggerType.getClass().getName());
}
 
Example #5
Source File: PayloadWrapperProcessor.java    From yang2swagger with Eclipse Public License 1.0 6 votes vote down vote up
private void processOperation(Operation operation, String propertyName) {
    if(operation == null) {
        return;
    }

    operation.getResponses().values().stream()
            .filter(r -> r.getSchema() instanceof RefProperty)
            .forEach(r -> wrap(propertyName, r));

    operation.getParameters().stream()
            .filter(p -> p instanceof BodyParameter)
            .map(p -> (BodyParameter) p)
            .filter(p -> p.getSchema() instanceof RefModel)
            .forEach(param -> wrap(propertyName, param));


}
 
Example #6
Source File: SwaggerRefHelper.java    From yang2swagger with Eclipse Public License 1.0 6 votes vote down vote up
public static String getFromBody(Operation oper) {
    Optional<Parameter> bodyParam =
            oper.getParameters().stream().filter(p -> p instanceof BodyParameter).findFirst();
    if(bodyParam.isPresent()) {
        Model schema = ((BodyParameter) bodyParam.get()).getSchema();
        if(schema instanceof RefModel) {
            return ((RefModel) schema).getSimpleRef();
        }
        if(schema instanceof ModelImpl) {
            Property input = schema.getProperties().get("input");
            if(input instanceof RefProperty)
                return ((RefProperty) input).getSimpleRef();
        }
    }

    return null;
}
 
Example #7
Source File: SwaggerUtils.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
public static Map<String, Property> getBodyProperties(Swagger swagger, Parameter parameter) {
  if (!(parameter instanceof BodyParameter)) {
    return null;
  }

  Model model = ((BodyParameter) parameter).getSchema();
  if (model instanceof RefModel) {
    model = swagger.getDefinitions().get(((RefModel) model).getSimpleRef());
  }

  if (model instanceof ModelImpl) {
    return model.getProperties();
  }

  return null;
}
 
Example #8
Source File: SwaggerUtils.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
/**
 * Provide a method to validate swagger. This method is now implemented to check common errors, and the logic
 * will be changed when necessary. For internal use only.
 */
public static void validateSwagger(Swagger swagger) {
  Map<String, Path> paths = swagger.getPaths();
  if (paths == null) {
    return;
  }

  for (Path path : paths.values()) {
    Operation operation = path.getPost();
    if (operation == null) {
      continue;
    }

    for (Parameter parameter : operation.getParameters()) {
      if (BodyParameter.class.isInstance(parameter) &&
          ((BodyParameter) parameter).getSchema() == null) {
        throw new ServiceCombException("swagger validator: body parameter schema is empty.");
      }
    }
  }
}
 
Example #9
Source File: PostOperationGenerator.java    From yang2swagger with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Operation execute(DataSchemaNode node) {
    final Operation post = dropLastSegmentParameters ? listOperation() : defaultOperation();
    final RefModel definition = new RefModel(getDefinitionId(node));
    post.summary("creates " + getName(node));
    String description = node.getDescription() == null ? "creates " + getName(node) :
            node.getDescription();
    post.description(description);
    post.parameter(new BodyParameter()
            .name(getName(node) + ".body-param")
            .schema(definition)
            .description(getName(node) + " to be added to list"));

    post.response(201, new Response().description("Object created"));
    post.response(409, new Response().description("Object already exists"));
    return post;
}
 
Example #10
Source File: AbstractOperationGenerator.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
private void mergeBodyParameter(BodyParameter bodyParameter, BodyParameter fromBodyParameter) {
  if (fromBodyParameter.getExamples() != null) {
    bodyParameter.setExamples(fromBodyParameter.getExamples());
  }
  if (fromBodyParameter.getRequired()) {
    bodyParameter.setRequired(true);
  }
  if (StringUtils.isNotEmpty(fromBodyParameter.getDescription())) {
    bodyParameter.setDescription(fromBodyParameter.getDescription());
  }
  if (StringUtils.isNotEmpty(fromBodyParameter.getAccess())) {
    bodyParameter.setAccess(fromBodyParameter.getAccess());
  }
  if (fromBodyParameter.getSchema() != null) {
    bodyParameter.setSchema(fromBodyParameter.getSchema());
  }
}
 
Example #11
Source File: AbstractOperationGenerator.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
protected void fillBodyParameter(Swagger swagger, Parameter parameter, Type type, List<Annotation> annotations) {
  // so strange, for bodyParameter, swagger return a new instance
  // that will cause lost some information
  // so we must merge them
  BodyParameter newBodyParameter = (BodyParameter) io.swagger.util.ParameterProcessor.applyAnnotations(
      swagger, parameter, type, annotations);

  // swagger missed enum data, fix it
  ModelImpl model = SwaggerUtils.getModelImpl(swagger, newBodyParameter);
  if (model != null) {
    Property property = ModelConverters.getInstance().readAsProperty(type);
    if (property instanceof StringProperty) {
      model.setEnum(((StringProperty) property).getEnum());
    }
  }

  mergeBodyParameter((BodyParameter) parameter, newBodyParameter);
}
 
Example #12
Source File: AbstractOperationGenerator.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
protected Parameter createParameter(HttpParameterType httpParameterType) {
  switch (httpParameterType) {
    case PATH:
      return new PathParameter();
    case QUERY:
      return new QueryParameter();
    case HEADER:
      return new HeaderParameter();
    case FORM:
      return new FormParameter();
    case COOKIE:
      return new CookieParameter();
    case BODY:
      return new BodyParameter();
    default:
      throw new IllegalStateException("not support httpParameterType " + httpParameterType);
  }
}
 
Example #13
Source File: PutOperationGenerator.java    From yang2swagger with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Operation execute(DataSchemaNode node) {
    final Operation put = defaultOperation();
    final RefModel definition = new RefModel(getDefinitionId(node));
    put.summary("creates or updates " + getName(node));
    String description = node.getDescription() == null ? "creates or updates " + getName(node) :
            node.getDescription();
    put.description(description);
    put.parameter(new BodyParameter()
            .name(getName(node) + ".body-param")
            .schema(definition)
            .description(getName(node) + " to be added or updated"));

    put.response(201, new Response().description("Object created"));
    put.response(204, new Response().description("Object modified"));
    return put;
}
 
Example #14
Source File: PatchOperationGenerator.java    From yang2swagger with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Operation execute(DataSchemaNode node) {
    final Operation patch = defaultOperation();
    final RefModel definition = new RefModel(getDefinitionId(node));
    patch.summary("patches " + getName(node));
    String description = node.getDescription() == null ? "patches " + getName(node) :
            node.getDescription();
    patch.description(description);
    patch.parameter(new BodyParameter()
            .name(getName(node) + ".body-param")
            .schema(definition)
            .description(getName(node) + " to be added or updated"));

    patch.response(200, new Response()
            .schema(new RefProperty(getDefinitionId(node)))
            .description(getName(node)));
    patch.response(204, new Response().description("Operation successful"));
    return patch;
}
 
Example #15
Source File: JaxrsReader.java    From swagger-maven-plugin with Apache License 2.0 6 votes vote down vote up
private Parameter replaceArrayModelForOctetStream(Operation operation, Parameter parameter) {
    if (parameter instanceof BodyParameter
            && operation.getConsumes() != null
            && operation.getConsumes().contains("application/octet-stream")) {
        BodyParameter bodyParam = (BodyParameter) parameter;
        Model schema = bodyParam.getSchema();
        if (schema instanceof ArrayModel) {
            ArrayModel arrayModel = (ArrayModel) schema;
            Property items = arrayModel.getItems();
            if (items != null && items.getFormat() == "byte" && items.getType() == "string") {
                ModelImpl model = new ModelImpl();
                model.setFormat("byte");
                model.setType("string");
                bodyParam.setSchema(model);
            }
        }
    }
    return parameter;
}
 
Example #16
Source File: ReaderTest.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
@Test
public void testRead() {
    Map<Class<?>, Object> interfaceMapRef = new HashMap<>();
    interfaceMapRef.put(TestSwaggerService.class, new TestSwaggerServiceImpl());
    Swagger swagger = new Swagger();
    swagger.setBasePath("/rest/");
    Reader.read(swagger, interfaceMapRef, "");

    Assert.assertEquals("2.0", swagger.getSwagger());
    Assert.assertEquals("/rest/", swagger.getBasePath());
    Map<String, Path> paths = swagger.getPaths();
    Assert.assertEquals(TestSwaggerService.class.getMethods().length, paths.size());
    Assert.assertTrue(paths.containsKey(COMPLEX));
    List<Parameter> parameters = paths.get(COMPLEX).getPost().getParameters();
    Assert.assertTrue(CommonUtils.isNotEmpty(parameters));
    Parameter parameter = parameters.get(0);
    Assert.assertTrue(parameter instanceof BodyParameter);
    Model schema = ((BodyParameter) parameter).getSchema();
    Assert.assertTrue(schema instanceof RefModel);
    String ref = ((RefModel) schema).get$ref();
    Assert.assertEquals("#/definitions/ComplexPojo", ref);

}
 
Example #17
Source File: ResourceReaderExtension.java    From mdw with Apache License 2.0 6 votes vote down vote up
/**
 * Implemented to allow loading of custom types using PackageClassLoader.
 */
@Override
public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) {
    // copied from io.swagger.servlet.extensions.ServletReaderExtension
    final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
    if (implicitParams != null && implicitParams.value().length > 0) {
        for (ApiImplicitParam param : implicitParams.value()) {
            final Parameter p = readImplicitParameter(context.getSwagger(), param);
            if (p != null) {
                if (p instanceof BodyParameter && param.format() != null)
                    p.getVendorExtensions().put("format", param.format());
                operation.parameter(p);
            }
        }
    }
}
 
Example #18
Source File: RpcReaderExtension.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
private Parameter readParam(Swagger swagger, Type type, Class<?> cls, ApiParam param) {
    PrimitiveType fromType = PrimitiveType.fromType(type);
    final Parameter para = null == fromType ? new BodyParameter() : new QueryParameter();
    Parameter parameter = ParameterProcessor.applyAnnotations(swagger, para, type,
        null == param ? new ArrayList<Annotation>()
            : Collections.<Annotation> singletonList(param));
    if (parameter instanceof AbstractSerializableParameter) {
        final AbstractSerializableParameter<?> p = (AbstractSerializableParameter<?>) parameter;
        if (p.getType() == null) {
            p.setType(null == fromType ? "string" : fromType.getCommonName());
        }
        p.setRequired(p.getRequired() || cls.isPrimitive());
    } else {
        //hack: Get the from data model paramter from BodyParameter
        BodyParameter bp = (BodyParameter) parameter;
        bp.setIn("body");
        Property property = ModelConverters.getInstance().readAsProperty(type);
        final Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<PropertyBuilder.PropertyId, Object>(
            PropertyBuilder.PropertyId.class);
        bp.setSchema(PropertyBuilder.toModel(PropertyBuilder.merge(property, args)));
    }
    return parameter;
}
 
Example #19
Source File: DubboReaderExtension.java    From swagger-dubbo with Apache License 2.0 6 votes vote down vote up
private Parameter readParam(Swagger swagger, Type type,Class<?> cls, ApiParam param) {
	PrimitiveType fromType = PrimitiveType.fromType(type);
	final Parameter para = null == fromType ? new BodyParameter() : new QueryParameter();
	Parameter parameter = ParameterProcessor.applyAnnotations(swagger, para,
			type == null ? String.class : type, null == param ? new ArrayList<Annotation>()
					: Collections.<Annotation> singletonList(param));
	if (parameter instanceof AbstractSerializableParameter) {
		final AbstractSerializableParameter<?> p = (AbstractSerializableParameter<?>) parameter;
		if (p.getType() == null) p.setType(null == fromType ? "string" : fromType.getCommonName());
		p.setRequired(p.getRequired() == true ? true : cls.isPrimitive());
	}else{
	    //hack: Get the from data model paramter from BodyParameter
	    BodyParameter bp = (BodyParameter)parameter;
	    bp.setIn("formData");
	}
	return parameter;
}
 
Example #20
Source File: NotEmptyBodyRule.java    From swagger-coverage with Apache License 2.0 6 votes vote down vote up
@Override
public Condition processParameter(Parameter parameter) {
    if (parameter instanceof BodyParameter) {


        ConditionPredicate predicate = new DefaultBodyConditionPredicate();

        return new SinglePredicateCondition(
                "not empty body request",
                "",
                predicate
        );
    }

    return null;
}
 
Example #21
Source File: ApiGatewaySdkSwaggerApiImporter.java    From aws-apigateway-importer with Apache License 2.0 5 votes vote down vote up
private Optional<String> getInputModel(BodyParameter p) {
    io.swagger.models.Model model = p.getSchema();

    if (model instanceof RefModel) {
        String modelName = ((RefModel) model).getSimpleRef();   // assumption: complex ref?
        return Optional.of(modelName);
    }

    return Optional.empty();
}
 
Example #22
Source File: JaxrsReaderTest.java    From swagger-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void handleOctetStreamAndByteArray() {
    Swagger result = reader.read(AnApiWithOctetStream.class);
    io.swagger.models.Path path = result.getPaths().get("/apath/add");
    assertNotNull(path, "Expecting to find a path ..");
    assertNotNull(path.getPost(), ".. with post opertion ..");
    assertNotNull(path.getPost().getConsumes().contains("application/octet-stream"), ".. and with octect-stream consumer.");
    assertTrue(path.getPost().getParameters().get(0) instanceof BodyParameter, "The parameter is a body parameter ..");
    assertFalse(((BodyParameter) path.getPost().getParameters().get(0)).getSchema() instanceof ArrayModel, " .. and the schema is NOT an ArrayModel");
}
 
Example #23
Source File: TestBodyProcessorCreator.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateRawJson() {
  ParamValueProcessorCreator creator =
      ParamValueProcessorCreatorManager.INSTANCE.findValue(BodyProcessorCreator.PARAMTYPE);
  BodyParameter param = new BodyParameter();
  param.setVendorExtension(SwaggerConst.EXT_RAW_JSON_TYPE, true);

  ParamValueProcessor processor = creator.create(param, String.class);

  Assert.assertEquals(RawJsonBodyProcessor.class, processor.getClass());
}
 
Example #24
Source File: SequenceGenerator.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
private static void populateParametersFromOperation(Operation operation, Map<String, Model> definitions,
        Map<String, String> parameterJsonPathMapping, Map<String, String> queryParameters) {

    List<Parameter> parameters = operation.getParameters();
    for (Parameter parameter : parameters) {
        String name = parameter.getName();
        if (parameter instanceof BodyParameter) {
            Model schema = ((BodyParameter) parameter).getSchema();
            if (schema instanceof RefModel) {
                String $ref = ((RefModel) schema).get$ref();
                if (StringUtils.isNotBlank($ref)) {
                    String defName = $ref.substring("#/definitions/".length());
                    Model model = definitions.get(defName);
                    Example example = ExampleBuilder.fromModel(defName, model, definitions, new HashSet<String>());

                    String jsonExample = Json.pretty(example);
                    try {
                        org.json.JSONObject json = new org.json.JSONObject(jsonExample);
                        SequenceUtils.listJson(json, parameterJsonPathMapping);
                    } catch (JSONException e) {
                        log.error("Error occurred while generating json mapping for the definition: " + defName, e);
                    }
                }
            }
        }
        if (parameter instanceof QueryParameter) {
            String type = ((QueryParameter) parameter).getType();
            queryParameters.put(name, type);
        }
    }
}
 
Example #25
Source File: ReplaceDefinitionsProcessor.java    From yang2swagger with Eclipse Public License 1.0 5 votes vote down vote up
private void fixParameter(Parameter p, Map<String, String> replacements) {
    if(!(p instanceof BodyParameter)) return;
    BodyParameter bp = (BodyParameter) p;
    if(!(bp.getSchema() instanceof RefModel)) return;
    RefModel ref = (RefModel) bp.getSchema();
    if(replacements.containsKey(ref.getSimpleRef())) {
        String replacement = replacements.get(ref.getSimpleRef());
        bp.setDescription(bp.getDescription().replace(ref.getSimpleRef(), replacement));
        bp.setSchema(new RefModel(replacement));
    }

}
 
Example #26
Source File: SwaggerInventory.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
public void process(Parameter parameter) {
    this.parameters.add(parameter);
    if(parameter instanceof BodyParameter) {
        BodyParameter p = (BodyParameter)parameter;
        if(p.getSchema() != null) {
            Model model = p.getSchema();
            if(model != null) {
                this.process(model);
            }
        }
    }

}
 
Example #27
Source File: SwaggerConverter.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
private RequestBody convertParameterToRequestBody(io.swagger.models.parameters.Parameter param, List<String> consumes) {
    RequestBody body = new RequestBody();
    BodyParameter bp = (BodyParameter) param;

    List<String> mediaTypes = new ArrayList<>(globalConsumes);
    if (consumes != null && consumes.size() > 0) {
        mediaTypes.clear();
        mediaTypes.addAll(consumes);
    }

    if (mediaTypes.size() == 0) {
        mediaTypes.add("*/*");
    }

    if (StringUtils.isNotBlank(param.getDescription())) {
        body.description(param.getDescription());
    }
    body.required(param.getRequired());

    Content content = new Content();
    for (String type : mediaTypes) {
        content.addMediaType(type,
                new MediaType().schema(
                        convert(bp.getSchema())));
        if (StringUtils.isNotBlank(bp.getDescription())) {
            body.setDescription(bp.getDescription());
        }
    }
    convertExamples(((BodyParameter) param).getExamples(), content);
    body.content(content);
    return body;
}
 
Example #28
Source File: ApiGatewaySdkSwaggerApiImporter.java    From aws-apigateway-importer with Apache License 2.0 5 votes vote down vote up
public void createMethod(RestApi api, Resource resource, String httpMethod,
                         Operation op, String modelContentType) {
    PutMethodInput input = new PutMethodInput();

    input.setAuthorizationType(getAuthorizationType(op));
    input.setApiKeyRequired(isApiKeyRequired(op));

    // set input model if present in body
    op.getParameters().stream().filter(p -> p.getIn().equals("body")).forEach(p -> {
        BodyParameter bodyParam = (BodyParameter) p;
        Optional<String> inputModel = getInputModel(bodyParam);

        input.setRequestModels(new HashMap<>());
        // model already imported
        if (inputModel.isPresent()) {
            this.processedModels.add(inputModel.get());
            LOG.info("Found input model reference " + inputModel.get());
            input.getRequestModels().put(modelContentType, inputModel.get());
        } else {
            // create new model from nested schema
            String modelName = generateModelName(bodyParam);
            LOG.info("Creating new model referenced from parameter: " + modelName);

            if (bodyParam.getSchema() == null) {
                throw new IllegalArgumentException("Body parameter '" + bodyParam.getName() + "' must have a schema defined");
            }

            createModel(api, modelName, bodyParam.getSchema(), swagger.getDefinitions(), modelContentType);
            input.getRequestModels().put(modelContentType, modelName);
        }
    });

    // create method
    Method method = resource.putMethod(input, httpMethod.toUpperCase());

    createMethodResponses(api, method, modelContentType, op.getResponses());
    createMethodParameters(api, method, op.getParameters());
    createIntegration(method, op.getVendorExtensions());
}
 
Example #29
Source File: SwaggerWorkflowReader.java    From mdw with Apache License 2.0 5 votes vote down vote up
private io.swagger.models.parameters.Parameter createParam(ParameterType paramType) {
    if (paramType == ParameterType.Path)
        return new PathParameter();
    else if (paramType == ParameterType.Query)
        return new QueryParameter();
    else if (paramType == ParameterType.Form)
        return new FormParameter();
    else if (paramType == ParameterType.Header)
        return new HeaderParameter();
    else if (paramType == ParameterType.Body)
        return new BodyParameter();
    return null;
}
 
Example #30
Source File: ResourceReaderExtension.java    From mdw with Apache License 2.0 5 votes vote down vote up
private Parameter createParam(String paramType) {
    if ("path".equals(paramType))
        return new PathParameter();
    else if ("query".equals(paramType))
        return new QueryParameter();
    else if ("form".equals(paramType))
        return new FormParameter();
    else if ("formData".equals(paramType))
        return new FormParameter();
    else if ("header".equals(paramType))
        return new HeaderParameter();
    else if ("body".equals(paramType))
        return new BodyParameter();
    return null;
}