io.swagger.models.properties.MapProperty Java Examples
The following examples show how to use
io.swagger.models.properties.MapProperty.
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: SwaggerInventory.java From swagger-parser with Apache License 2.0 | 6 votes |
public void process(Property property) { this.properties.add(property); if(property instanceof ArrayProperty) { ArrayProperty p = (ArrayProperty)property; Property ap = p.getItems(); this.process(ap); } else if(property instanceof MapProperty) { MapProperty p1 = (MapProperty)property; } else if(property instanceof ObjectProperty) { ObjectProperty p2 = (ObjectProperty)property; if(p2.getProperties() != null) { Iterator ap1 = p2.getProperties().keySet().iterator(); while(ap1.hasNext()) { String name = (String)ap1.next(); Property ip = (Property)p2.getProperties().get(name); this.process(ip); } } } }
Example #2
Source File: PropertyAdapter.java From swagger2markup with Apache License 2.0 | 6 votes |
/** * Return example display string for the given {@code property}. * * @param generateMissingExamples specifies if missing examples should be generated * @param markupDocBuilder doc builder * @return property example display string */ public Optional<Object> getExample(boolean generateMissingExamples, MarkupDocBuilder markupDocBuilder) { if (property.getExample() != null) { return Optional.ofNullable(property.getExample()); } else if (property instanceof MapProperty) { Property additionalProperty = ((MapProperty) property).getAdditionalProperties(); if (additionalProperty.getExample() != null) { return Optional.ofNullable(additionalProperty.getExample()); } else if (generateMissingExamples) { Map<String, Object> exampleMap = new HashMap<>(); exampleMap.put("string", generateExample(additionalProperty, markupDocBuilder)); return Optional.of(exampleMap); } } else if (property instanceof ArrayProperty) { if (generateMissingExamples) { Property itemProperty = ((ArrayProperty) property).getItems(); List<Object> exampleArray = new ArrayList<>(); exampleArray.add(generateExample(itemProperty, markupDocBuilder)); return Optional.of(exampleArray); } } else if (generateMissingExamples) { return Optional.of(generateExample(property, markupDocBuilder)); } return Optional.empty(); }
Example #3
Source File: ConverterMgr.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
private static void initConverters() { // inner converters for (Class<? extends Property> propertyCls : PROPERTY_MAP.keySet()) { addInnerConverter(propertyCls); } converterMap.put(RefProperty.class, new RefPropertyConverter()); converterMap.put(ArrayProperty.class, new ArrayPropertyConverter()); converterMap.put(MapProperty.class, new MapPropertyConverter()); converterMap.put(StringProperty.class, new StringPropertyConverter()); converterMap.put(ObjectProperty.class, new ObjectPropertyConverter()); converterMap.put(ModelImpl.class, new ModelImplConverter()); converterMap.put(RefModel.class, new RefModelConverter()); converterMap.put(ArrayModel.class, new ArrayModelConverter()); }
Example #4
Source File: AbstractKotlinCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
/** * Output the type declaration of the property * * @param p Swagger Property object * @return a string presentation of the property type */ @Override public String getTypeDeclaration(Property p) { if (p instanceof ArrayProperty) { return getArrayTypeDeclaration((ArrayProperty) p); } else if (p instanceof MapProperty) { MapProperty mp = (MapProperty) p; Property inner = mp.getAdditionalProperties(); // Maps will be keyed only by primitive Kotlin string return getSwaggerType(p) + "<kotlin.String, " + getTypeDeclaration(inner) + ">"; } return super.getTypeDeclaration(p); }
Example #5
Source File: ResponseContainerConverter.java From swagger-maven-plugin with Apache License 2.0 | 5 votes |
Property withResponseContainer(String responseContainer, Property property) { if ("list".equalsIgnoreCase(responseContainer)) { return new ArrayProperty(property); } if ("set".equalsIgnoreCase(responseContainer)) { return new ArrayProperty(property).uniqueItems(); } if ("map".equalsIgnoreCase(responseContainer)) { return new MapProperty(property); } return property; }
Example #6
Source File: PropertyAdapter.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override public Property getMapItem() { if (property instanceof MapProperty) { return ((MapProperty) property).getAdditionalProperties(); } return null; }
Example #7
Source File: SwaggerUtils.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static boolean isComplexProperty(Property property) { if (property instanceof RefProperty || property instanceof ObjectProperty || property instanceof MapProperty) { return true; } if (ArrayProperty.class.isInstance(property)) { return isComplexProperty(((ArrayProperty) property).getItems()); } return false; }
Example #8
Source File: FlashClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public String getTypeDeclaration(Property p) { if (p instanceof ArrayProperty || p instanceof MapProperty) { return getSwaggerType(p); } return super.getTypeDeclaration(p); }
Example #9
Source File: TizenClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public String toDefaultValue(Property p) { if (p instanceof StringProperty) { return "std::string()"; } else if (p instanceof BooleanProperty) { return "bool(false)"; } else if (p instanceof DoubleProperty) { return "double(0)"; } else if (p instanceof FloatProperty) { return "float(0)"; } else if (p instanceof IntegerProperty) { return "int(0)"; } else if (p instanceof LongProperty) { return "long(0)"; } else if (p instanceof DecimalProperty) { return "long(0)"; } else if (p instanceof MapProperty) { return "new std::map()"; } else if (p instanceof ArrayProperty) { return "new std::list()"; } // else if (p instanceof RefProperty) { RefProperty rp = (RefProperty) p; return "new " + toModelName(rp.getSimpleRef()) + "()"; } return "null"; }
Example #10
Source File: TizenClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public String toInstantiationType(Property p) { if (p instanceof MapProperty) { return instantiationTypes.get("map"); } else if (p instanceof ArrayProperty) { return instantiationTypes.get("array"); } else { return null; } }
Example #11
Source File: DartClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public String toDefaultValue(Property p) { if (p instanceof MapProperty) { return "{}"; } else if (p instanceof ArrayProperty) { return "[]"; } return super.toDefaultValue(p); }
Example #12
Source File: Reader.java From dorado with Apache License 2.0 | 4 votes |
@Override protected Property doWrap(Property property) { return new MapProperty(property); }
Example #13
Source File: RpcReaderExtension.java From sofa-rpc with Apache License 2.0 | 4 votes |
@Override protected Property doWrap(Property property) { return new MapProperty(property); }
Example #14
Source File: Reader.java From proteus with Apache License 2.0 | 4 votes |
@Override protected Property doWrap(Property property) { return new MapProperty(property); }
Example #15
Source File: DubboReaderExtension.java From swagger-dubbo with Apache License 2.0 | 4 votes |
@Override protected Property doWrap(Property property) { return new MapProperty(property); }
Example #16
Source File: ControllerReaderExtension.java From jboot with Apache License 2.0 | 4 votes |
@Override protected Property doWrap(Property property) { return new MapProperty(property); }
Example #17
Source File: MapPropertyConverter.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Override public JavaType doConvert(Swagger swagger, Object property) { MapProperty mapProperty = (MapProperty) property; Property valueProperty = mapProperty.getAdditionalProperties(); return findJavaType(swagger, valueProperty); }
Example #18
Source File: DefaultCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, ModelImpl swaggerModel) { MapProperty mapProperty = new MapProperty(swaggerModel.getAdditionalProperties()); addParentContainer(codegenModel, codegenModel.name, mapProperty); }
Example #19
Source File: DefaultCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
/** * returns the swagger type for the property * @param p Swagger property object * @return string presentation of the type **/ @SuppressWarnings("static-method") public String getSwaggerType(Property p) { String datatype = null; if (p instanceof StringProperty && "number".equals(p.getFormat())) { datatype = "BigDecimal"; } else if ((p instanceof ByteArrayProperty) || (p instanceof StringProperty && "byte".equals(p.getFormat()))) { datatype = "ByteArray"; } else if (p instanceof BinaryProperty) { datatype = "binary"; } else if (p instanceof FileProperty) { datatype = "file"; } else if (p instanceof BooleanProperty) { datatype = "boolean"; } else if (p instanceof DateProperty) { datatype = "date"; } else if (p instanceof DateTimeProperty) { datatype = "DateTime"; } else if (p instanceof DoubleProperty) { datatype = "double"; } else if (p instanceof FloatProperty) { datatype = "float"; } else if (p instanceof IntegerProperty) { datatype = "integer"; } else if (p instanceof LongProperty) { datatype = "long"; } else if (p instanceof MapProperty) { datatype = "map"; } else if (p instanceof DecimalProperty) { datatype = "number"; } else if ( p instanceof UUIDProperty) { datatype = "UUID"; } else if (p instanceof RefProperty) { try { RefProperty r = (RefProperty) p; datatype = r.get$ref(); if (datatype.indexOf("#/definitions/") == 0) { datatype = datatype.substring("#/definitions/".length()); } } catch (Exception e) { LOGGER.warn("Error obtaining the datatype from RefProperty:" + p + ". Datatype default to Object"); datatype = "Object"; LOGGER.error(e.getMessage(), e); } } else if (p instanceof StringProperty) { datatype = "string"; } else { if (p != null) { datatype = p.getType(); } } return datatype; }
Example #20
Source File: ExtendedSwaggerReader.java From msf4j with Apache License 2.0 | 4 votes |
@Override protected Property doWrap(Property property) { return new MapProperty(property); }