use of io.swagger.v3.oas.models.media.StringSchema in project swagger-parser by swagger-api.
the class OpenAPIResolverTest method testSharedPathParametersTest.
@Test(description = "resolve shared path parameters")
public void testSharedPathParametersTest() {
final OpenAPI swagger = new OpenAPI();
Operation operation = new Operation().responses(new ApiResponses().addApiResponse("200", new ApiResponse().description("ok!")));
PathItem path = new PathItem().get(operation);
path.addParametersItem(new QueryParameter().name("username").schema(new StringSchema()));
swagger.path("/fun", path);
final OpenAPI resolved = new OpenAPIResolver(swagger, null).resolve();
assertNull(resolved.getPaths().get("/fun").getParameters());
assertTrue(resolved.getPaths().get("/fun").getGet().getParameters().size() == 1);
}
use of io.swagger.v3.oas.models.media.StringSchema in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue146.
@Test
public void testIssue146() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
final OpenAPI openAPI = parser.read("src/test/resources/issue_146.yaml");
assertNotNull(openAPI);
QueryParameter p = ((QueryParameter) openAPI.getPaths().get("/checker").getGet().getParameters().get(0));
StringSchema pp = (StringSchema) ((ArraySchema) p.getSchema()).getItems();
assertTrue("registration".equalsIgnoreCase(pp.getEnum().get(0)));
}
use of io.swagger.v3.oas.models.media.StringSchema in project flow by vaadin.
the class SchemaResolverTest method should_ReturnNullableArray_When_GivenTypeIsAListString.
@Test
public void should_ReturnNullableArray_When_GivenTypeIsAListString() {
ResolvedType resolvedType = mockReferencedTypeOf(Collection.class);
ResolvedReferenceType resolvedReferenceType = resolvedType.asReferenceType();
List<Pair<ResolvedTypeParameterDeclaration, ResolvedType>> pairs = Collections.singletonList(new Pair<>(null, mockReferencedTypeOf(String.class)));
when(resolvedReferenceType.getTypeParametersMap()).thenReturn(pairs);
Map<String, GeneratorType> usedTypes = new HashMap<>();
SchemaResolver schemaResolver = new SchemaResolver(new GeneratorType(resolvedType), usedTypes);
Schema schema = schemaResolver.resolve();
Assert.assertTrue(schema instanceof ArraySchema);
Assert.assertTrue(schema.getNullable());
Assert.assertTrue(((ArraySchema) schema).getItems() instanceof StringSchema);
Assert.assertTrue(usedTypes.isEmpty());
}
use of io.swagger.v3.oas.models.media.StringSchema in project flow by vaadin.
the class SchemaResolverTest method should_ReturnNullableOptional_When_GivenTypeIsAnOptionalString.
@Test
public void should_ReturnNullableOptional_When_GivenTypeIsAnOptionalString() {
ResolvedType resolvedType = mockReferencedTypeOf(Optional.class);
ResolvedReferenceType resolvedReferenceType = resolvedType.asReferenceType();
List<Pair<ResolvedTypeParameterDeclaration, ResolvedType>> pairs = Collections.singletonList(new Pair<>(null, mockReferencedTypeOf(String.class)));
when(resolvedReferenceType.getTypeParametersMap()).thenReturn(pairs);
Map<String, GeneratorType> usedTypes = new HashMap<>();
SchemaResolver schemaResolver = new SchemaResolver(new GeneratorType(resolvedType), usedTypes);
Schema schema = schemaResolver.resolve();
Assert.assertTrue(schema instanceof StringSchema);
Assert.assertTrue(schema.getNullable());
Assert.assertTrue(usedTypes.isEmpty());
}
use of io.swagger.v3.oas.models.media.StringSchema in project flow by vaadin.
the class SchemaResolver method createEnumTypeSchema.
private Schema createEnumTypeSchema() {
ResolvedReferenceType resolvedReferenceType = type.asResolvedType().asReferenceType();
List<String> entries = resolvedReferenceType.getTypeDeclaration().orElseThrow(IllegalArgumentException::new).asEnum().getEnumConstants().stream().map(ResolvedEnumConstantDeclaration::getName).collect(Collectors.toList());
String qualifiedName = resolvedReferenceType.getQualifiedName();
usedTypes.put(qualifiedName, type);
StringSchema schema = new StringSchema();
schema.name(qualifiedName);
schema.setEnum(entries);
schema.$ref(getFullQualifiedNameRef(qualifiedName));
return schema;
}
Aggregations