|
| 1 | +package io.swagger.v3.core.resolving.v31; |
| 2 | + |
| 3 | +import io.swagger.v3.core.converter.AnnotatedType; |
| 4 | +import io.swagger.v3.core.converter.ModelConverterContextImpl; |
| 5 | +import io.swagger.v3.core.jackson.ModelResolver; |
| 6 | +import io.swagger.v3.core.matchers.SerializationMatchers; |
| 7 | +import io.swagger.v3.core.resolving.SwaggerTestBase; |
| 8 | +import org.testng.annotations.Test; |
| 9 | + |
| 10 | +public class Ticket3900Test extends SwaggerTestBase { |
| 11 | + |
| 12 | + @Test |
| 13 | + public void testArraySchemaItemsValidation() { |
| 14 | + final ModelResolver modelResolver = new ModelResolver(mapper()).openapi31(true); |
| 15 | + final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver); |
| 16 | + io.swagger.v3.oas.models.media.Schema model = context.resolve(new AnnotatedType(Route.class)); |
| 17 | + SerializationMatchers.assertEqualsToYaml31(model, "type: object\n" + |
| 18 | + "properties:\n" + |
| 19 | + " startPoint:\n" + |
| 20 | + " $ref: '#/components/schemas/GeoPoint'\n" + |
| 21 | + " description: Point where the route begins\n" + |
| 22 | + " intermediatePoint:\n" + |
| 23 | + " $ref: '#/components/schemas/GeoPoint'\n" + |
| 24 | + " description: Intermediate point of the route\n" + |
| 25 | + " endPoint:\n" + |
| 26 | + " $ref: '#/components/schemas/GeoPoint'\n" + |
| 27 | + " description: Point where the route ends"); |
| 28 | + } |
| 29 | + |
| 30 | + private static class GeoPoint { |
| 31 | + |
| 32 | + @io.swagger.v3.oas.annotations.media.Schema(description = "Longitude of geo point ( -180, 180 >") |
| 33 | + public double lon; |
| 34 | + |
| 35 | + @io.swagger.v3.oas.annotations.media.Schema(description = "Latitude of geo point < -90, 90 >") |
| 36 | + public double lat; |
| 37 | + } |
| 38 | + |
| 39 | + private static class Route { |
| 40 | + @io.swagger.v3.oas.annotations.media.Schema(description = "Point where the route begins") |
| 41 | + public GeoPoint startPoint; |
| 42 | + |
| 43 | + @io.swagger.v3.oas.annotations.media.Schema(description = "Intermediate point of the route") |
| 44 | + public GeoPoint intermediatePoint; |
| 45 | + |
| 46 | + @io.swagger.v3.oas.annotations.media.Schema(description = "Point where the route ends") |
| 47 | + public GeoPoint endPoint; |
| 48 | + } |
| 49 | +} |
0 commit comments