Java Code Examples for io.swagger.v3.oas.models.parameters.Parameter#getExplode()
The following examples show how to use
io.swagger.v3.oas.models.parameters.Parameter#getExplode() .
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: GenericParameterBuilder.java From springdoc-openapi with Apache License 2.0 | 4 votes |
/** * Merge parameter. * * @param paramCalcul the param calcul * @param paramDoc the param doc */ private static void mergeParameter(Parameter paramCalcul, Parameter paramDoc) { if (StringUtils.isBlank(paramDoc.getDescription())) paramDoc.setDescription(paramCalcul.getDescription()); if (StringUtils.isBlank(paramDoc.getIn())) paramDoc.setIn(paramCalcul.getIn()); if (paramDoc.getExample() == null) paramDoc.setExample(paramCalcul.getExample()); if (paramDoc.getDeprecated() == null) paramDoc.setDeprecated(paramCalcul.getDeprecated()); if (paramDoc.getRequired() == null) paramDoc.setRequired(paramCalcul.getRequired()); if (paramDoc.getAllowEmptyValue() == null) paramDoc.setAllowEmptyValue(paramCalcul.getAllowEmptyValue()); if (paramDoc.getAllowReserved() == null) paramDoc.setAllowReserved(paramCalcul.getAllowReserved()); if (StringUtils.isBlank(paramDoc.get$ref())) paramDoc.set$ref(paramDoc.get$ref()); if (paramDoc.getSchema() == null) paramDoc.setSchema(paramCalcul.getSchema()); if (paramDoc.getExamples() == null) paramDoc.setExamples(paramCalcul.getExamples()); if (paramDoc.getExtensions() == null) paramDoc.setExtensions(paramCalcul.getExtensions()); if (paramDoc.getStyle() == null) paramDoc.setStyle(paramCalcul.getStyle()); if (paramDoc.getExplode() == null) paramDoc.setExplode(paramCalcul.getExplode()); }
Example 2
Source File: DefaultConverter.java From swagger-inflector with Apache License 2.0 | 4 votes |
public Object coerceValue(List<String> arguments, Parameter parameter, Class<?> cls) throws ConversionException { if (arguments == null || arguments.size() == 0) { return null; } LOGGER.debug("casting `" + arguments + "` to " + cls); if (List.class.equals(cls)) { if (parameter.getSchema() != null) { List<Object> output = new ArrayList<>(); if (parameter.getSchema() instanceof ArraySchema) { ArraySchema arraySchema = ((ArraySchema) parameter.getSchema()); Schema inner = arraySchema.getItems(); // TODO: this does not need to be done this way, update the helper method Parameter innerParam = new QueryParameter(); innerParam.setSchema(inner); JavaType innerClass = getTypeFromParameter(innerParam, definitions); for (String obj : arguments) { String[] parts = new String[0]; if (Parameter.StyleEnum.FORM.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj) && parameter.getExplode() == false ) { parts = obj.split(","); } if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj)) { parts = obj.split("|"); } if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj)) { parts = obj.split(" "); } if (Parameter.StyleEnum.FORM.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj) && parameter.getExplode() == true) { parts = new String[1]; parts[0]= obj; } for (String p : parts) { Object ob = cast(p, inner, innerClass); if (ob != null) { output.add(ob); } } } } return output; } } else if (parameter.getSchema() != null) { TypeFactory tf = Json.mapper().getTypeFactory(); return cast(arguments.get(0), parameter.getSchema(), tf.constructType(cls)); } return null; }
Example 3
Source File: DefaultConverter.java From swagger-inflector with Apache License 2.0 | 4 votes |
public Object cast(List<String> arguments, Parameter parameter, JavaType javaType, Map<String, Schema> definitions) throws ConversionException { if (arguments == null || arguments.size() == 0) { return null; } Class<?> cls = javaType.getRawClass(); LOGGER.debug("converting array `" + arguments + "` to `" + cls + "`"); if (javaType.isArrayType()) { if (parameter.getSchema() != null) { List<Object> output = new ArrayList<>(); if (parameter.getSchema() instanceof ArraySchema) { ArraySchema arraySchema = (ArraySchema) parameter.getSchema(); if (arraySchema.getItems() != null) { Schema inner = arraySchema.getItems(); // TODO: this does not need to be done this way, update the helper method Parameter innerParam = new QueryParameter().schema(inner); JavaType innerClass = getTypeFromParameter(innerParam, definitions); for (String obj : arguments) { String[] parts = new String[0]; CSVFormat format = null; if (Parameter.StyleEnum.FORM.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj) && parameter.getExplode() == false) { format = CSVFormat.DEFAULT; } else if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj)) { format = CSVFormat.newFormat('|').withQuote('"'); } else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle()) && !StringUtils.isEmpty(obj)) { format = CSVFormat.newFormat(' ').withQuote('"'); } if (format != null) { try { for (CSVRecord record : CSVParser.parse(obj, format).getRecords()) { List<String> it = new ArrayList<String>(); for (Iterator<String> x = record.iterator(); x.hasNext(); ) { it.add(x.next()); } parts = it.toArray(new String[it.size()]); } } catch (IOException e) { } } else { parts = new String[1]; parts[0] = obj; } for (String p : parts) { Object ob = cast(p, inner, innerClass); if (ob != null) { output.add(ob); } } } return output; } } } } else if (parameter != null) { return cast(arguments.get(0), parameter.getSchema(), javaType); } return null; }