io.swagger.v3.oas.models.media.UUIDSchema Java Examples

The following examples show how to use io.swagger.v3.oas.models.media.UUIDSchema. 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: ValueCoercionTest.java    From swagger-inflector with Apache License 2.0 5 votes vote down vote up
@Test
public void testConvertUUIDValue() throws Exception {
    List<String> values = Arrays.asList("163e1000-2a5a-4be2-b271-3470b63dff00");

    Parameter parameter = new QueryParameter().schema(new UUIDSchema());
    Object o = utils.cast(values, parameter, tf.constructType(UUID.class), null);

    assertTrue(o instanceof UUID);
}
 
Example #2
Source File: ValueCoercionTest.java    From swagger-inflector with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = ConversionException.class)
public void testConvertInvalidUUIDValue() throws Exception {
    List<String> values = Arrays.asList("bleh");

    Parameter parameter = new QueryParameter().schema(new UUIDSchema());
    Object o = utils.cast(values, parameter, tf.constructType(UUID.class), null);

    assertNull(o);
}
 
Example #3
Source File: SchemaTypeUtil.java    From swagger-parser with Apache License 2.0 4 votes vote down vote up
public static Schema createSchema(String type, String format) {

        if(INTEGER_TYPE.equals(type)) {
            if(StringUtils.isBlank(format)){
                return new IntegerSchema().format(null);
            }else {
                return new IntegerSchema().format(format);
            }
        }
        else if(NUMBER_TYPE.equals(type)) {
            if (StringUtils.isBlank(format)){
                return new NumberSchema();
            } else {
                return new NumberSchema().format(format);
            }
        }
        else if(BOOLEAN_TYPE.equals(type)) {
            if (StringUtils.isBlank(format)){
                return new BooleanSchema();
            } else {
                return new BooleanSchema().format(format);
            }
        }
        else if(STRING_TYPE.equals(type)) {
            if(BYTE_FORMAT.equals(format)) {
                return new ByteArraySchema();
            }
            else if(BINARY_FORMAT.equals(format)) {
                return new BinarySchema();
            }
            else if(DATE_FORMAT.equals(format)) {
                return new DateSchema();
            }
            else if(DATE_TIME_FORMAT.equals(format)) {
                return new DateTimeSchema();
            }
            else if(PASSWORD_FORMAT.equals(format)) {
                return new PasswordSchema();
            }
            else if(EMAIL_FORMAT.equals(format)) {
                return new EmailSchema();
            }
            else if(UUID_FORMAT.equals(format)) {
                return new UUIDSchema();
            }
            else {
                if (StringUtils.isBlank(format)){
                    return new StringSchema().format(null);
                }else {
                    return new StringSchema().format(format);
                }
            }
        }
        else if(OBJECT_TYPE.equals(type)) {
            return new ObjectSchema();
        }
        else {
            return new Schema();
        }
    }