io.swagger.models.properties.ByteArrayProperty Java Examples
The following examples show how to use
io.swagger.models.properties.ByteArrayProperty.
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: ConverterMgr.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
private static void initPropertyMap() { PROPERTY_MAP.put(BooleanProperty.class, TypeFactory.defaultInstance().constructType(Boolean.class)); PROPERTY_MAP.put(FloatProperty.class, TypeFactory.defaultInstance().constructType(Float.class)); PROPERTY_MAP.put(DoubleProperty.class, TypeFactory.defaultInstance().constructType(Double.class)); PROPERTY_MAP.put(DecimalProperty.class, TypeFactory.defaultInstance().constructType(BigDecimal.class)); PROPERTY_MAP.put(ByteProperty.class, TypeFactory.defaultInstance().constructType(Byte.class)); PROPERTY_MAP.put(ShortProperty.class, TypeFactory.defaultInstance().constructType(Short.class)); PROPERTY_MAP.put(IntegerProperty.class, TypeFactory.defaultInstance().constructType(Integer.class)); PROPERTY_MAP.put(BaseIntegerProperty.class, TypeFactory.defaultInstance().constructType(Integer.class)); PROPERTY_MAP.put(LongProperty.class, TypeFactory.defaultInstance().constructType(Long.class)); // stringProperty include enum scenes, not always be string type // if convert by StringPropertyConverter, can support enum scenes PROPERTY_MAP.put(StringProperty.class, TypeFactory.defaultInstance().constructType(String.class)); PROPERTY_MAP.put(DateProperty.class, TypeFactory.defaultInstance().constructType(LocalDate.class)); PROPERTY_MAP.put(DateTimeProperty.class, TypeFactory.defaultInstance().constructType(Date.class)); PROPERTY_MAP.put(ByteArrayProperty.class, TypeFactory.defaultInstance().constructType(byte[].class)); PROPERTY_MAP.put(FileProperty.class, TypeFactory.defaultInstance().constructType(Part.class)); }
Example #2
Source File: SwaggerGenerator.java From endpoints-java with Apache License 2.0 | 6 votes |
private static Property getSwaggerArrayProperty(TypeToken<?> typeToken) { Class<?> type = typeToken.getRawType(); if (type == String.class) { return new StringProperty(); } else if (type == Boolean.class || type == Boolean.TYPE) { return new BooleanProperty(); } else if (type == Integer.class || type == Integer.TYPE) { return new IntegerProperty(); } else if (type == Long.class || type == Long.TYPE) { return new LongProperty(); } else if (type == Float.class || type == Float.TYPE) { return new FloatProperty(); } else if (type == Double.class || type == Double.TYPE) { return new DoubleProperty(); } else if (type == byte[].class) { return new ByteArrayProperty(); } else if (type.isEnum()) { return new StringProperty(); } throw new IllegalArgumentException("invalid property type"); }
Example #3
Source File: TestArrayType.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void test() { SwaggerOperations swaggerOperations = SwaggerOperations.generate(ArrayType.class); SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testBytes"); BodyParameter bodyParameter = (BodyParameter) swaggerOperation.getOperation().getParameters().get(0); ModelImpl model = SwaggerUtils.getModelImpl(swaggerOperations.getSwagger(), bodyParameter); Assert.assertEquals(ModelImpl.OBJECT, model.getType()); Assert.assertEquals(1, model.getProperties().size()); ByteArrayProperty byteArrayProperty = (ByteArrayProperty) model.getProperties().get("value"); Assert.assertEquals("string", byteArrayProperty.getType()); Assert.assertEquals("byte", byteArrayProperty.getFormat()); }
Example #4
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 #5
Source File: ByteArrayPropertyCreator.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Override public Property createProperty() { return new ByteArrayProperty(); }
Example #6
Source File: InputStreamPropertyCreator.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Override public Property createProperty() { return new ByteArrayProperty(); }
Example #7
Source File: PropertyValidator.java From assertj-swagger with Apache License 2.0 | 4 votes |
private boolean shouldValidateByteArrayProperty(Property expectedProperty) { return ByteArrayProperty.class.isAssignableFrom(expectedProperty.getClass()) && isAssertionEnabled( SwaggerAssertionType.BYTE_ARRAY_PROPERTIES); }