@Test(dataProvider = "expectedSchemaFromTypeAndFormat") public void getSchema(String methodName, Map<String, Object> expected) throws NoSuchMethodException { final Method method = getClass().getDeclaredMethod(methodName); Content annotationContent = method.getAnnotation(ApiResponse.class).content()[0]; Optional<? extends Schema> schema = AnnotationsUtils.getSchema(annotationContent, new Components(), null); Assert.assertTrue(schema.isPresent()); Assert.assertEquals(schema.get().getType(), expected.get("type")); Assert.assertEquals(schema.get().getFormat(), expected.get("format")); Assert.assertEquals(schema.get().get$ref(), expected.get("$ref")); }
public static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation) { Class<?> schemaImplementation = annotationContent.schema().implementation(); boolean isArray = false; if (schemaImplementation == Void.class) { schemaImplementation = annotationContent.array().schema().implementation(); if (schemaImplementation != Void.class) { isArray = true; } } return getSchema(annotationContent.schema(), annotationContent.array(), isArray, schemaImplementation, components, jsonViewAnnotation); }
AnnotationsUtils { public static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation) { Class<?> schemaImplementation = annotationContent.schema().implementation(); boolean isArray = false; if (schemaImplementation == Void.class) { schemaImplementation = annotationContent.array().schema().implementation(); if (schemaImplementation != Void.class) { isArray = true; } } return getSchema(annotationContent.schema(), annotationContent.array(), isArray, schemaImplementation, components, jsonViewAnnotation); } }
AnnotationsUtils { public static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation) { Class<?> schemaImplementation = annotationContent.schema().implementation(); boolean isArray = false; if (schemaImplementation == Void.class) { schemaImplementation = annotationContent.array().schema().implementation(); if (schemaImplementation != Void.class) { isArray = true; } } return getSchema(annotationContent.schema(), annotationContent.array(), isArray, schemaImplementation, components, jsonViewAnnotation); }  }
AnnotationsUtils { public static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation) { Class<?> schemaImplementation = annotationContent.schema().implementation(); boolean isArray = false; if (schemaImplementation == Void.class) { schemaImplementation = annotationContent.array().schema().implementation(); if (schemaImplementation != Void.class) { isArray = true; } } return getSchema(annotationContent.schema(), annotationContent.array(), isArray, schemaImplementation, components, jsonViewAnnotation); }  static boolean hasSchemaAnnotation(io.swagger.v3.oas.annotations.media.Schema schema); static boolean equals(Annotation thisAnnotation, Annotation thatAnnotation); static boolean equals(io.swagger.v3.oas.annotations.media.ArraySchema thisArraySchema, io.swagger.v3.oas.annotations.media.ArraySchema thatArraySchema); static boolean equals(io.swagger.v3.oas.annotations.media.Schema thisSchema, io.swagger.v3.oas.annotations.media.Schema thatSchema); static boolean hasArrayAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema array); static Optional<Example> getExample(ExampleObject example); static Optional<Example> getExample(ExampleObject example, boolean ignoreName); static Optional<ArraySchema> getArraySchema(io.swagger.v3.oas.annotations.media.ArraySchema arraySchema, JsonView jsonViewAnnotation); static Optional<ArraySchema> getArraySchema(io.swagger.v3.oas.annotations.media.ArraySchema arraySchema, Components components, JsonView jsonViewAnnotation); static Optional<Schema> getSchemaFromAnnotation(io.swagger.v3.oas.annotations.media.Schema schema, JsonView jsonViewAnnotation); static Optional<Schema> getSchemaFromAnnotation(io.swagger.v3.oas.annotations.media.Schema schema, Components components, JsonView jsonViewAnnotation); static Schema resolveSchemaFromType(Class<?> schemaImplementation, Components components, JsonView jsonViewAnnotation); static Optional<Set<Tag>> getTags(io.swagger.v3.oas.annotations.tags.Tag[] tags, boolean skipOnlyName); static Optional<List<Server>> getServers(io.swagger.v3.oas.annotations.servers.Server[] servers); static Optional<Server> getServer(io.swagger.v3.oas.annotations.servers.Server server); static Optional<ExternalDocumentation> getExternalDocumentation(io.swagger.v3.oas.annotations.ExternalDocumentation externalDocumentation); static Optional<Info> getInfo(io.swagger.v3.oas.annotations.info.Info info); static Optional<Contact> getContact(io.swagger.v3.oas.annotations.info.Contact contact); static Optional<License> getLicense(io.swagger.v3.oas.annotations.info.License license); static Map<String, Link> getLinks(io.swagger.v3.oas.annotations.links.Link[] links); static Optional<Link> getLink(io.swagger.v3.oas.annotations.links.Link link); static Map<String, String> getLinkParameters(LinkParameter[]
                                                                linkParameter); static Optional<Map<String, Header>> getHeaders(io.swagger.v3.oas.annotations.headers.Header[] annotationHeaders, JsonView jsonViewAnnotation); static Optional<Header> getHeader(io.swagger.v3.oas.annotations.headers.Header header, JsonView jsonViewAnnotation); static void addEncodingToMediaType(MediaType mediaType, io.swagger.v3.oas.annotations.media.Encoding encoding, JsonView jsonViewAnnotation); static Type getSchemaType(io.swagger.v3.oas.annotations.media.Schema schema); static Type getSchemaType(io.swagger.v3.oas.annotations.media.Schema schema, boolean nullIfNotFound); static Optional<Content> getContent(io.swagger.v3.oas.annotations.media.Content[] annotationContents, String[] classTypes, String[] methodTypes, Schema schema, Components components, JsonView jsonViewAnnotation); static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation); static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Schema schemaAnnotation,
                                                       io.swagger.v3.oas.annotations.media.ArraySchema arrayAnnotation,
                                                       boolean isArray,
                                                       Class<?> schemaImplementation,
                                                       Components components,
                                                       JsonView jsonViewAnnotation); static void applyTypes(String[] classTypes, String[] methodTypes, Content content, MediaType mediaType); static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Annotated a); static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Annotated a); static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Class<?> cls); static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Class<?> cls); static Map<String, Object> getExtensions(Extension... extensions); static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Annotation... annotations); static io.swagger.v3.oas.annotations.media.ArraySchema getArraySchemaAnnotation(Annotation... annotations); static T getAnnotation(Class<T> cls, Annotation... annotations); static Annotation[] removeAnnotations(Annotation[] annotations, Class ... classes); static void updateAnnotation(Class<?> clazz, io.swagger.v3.oas.annotations.media.Schema newAnnotation); static Annotation mergeSchemaAnnotations(
            Annotation[] ctxAnnotations, JavaType type); static io.swagger.v3.oas.annotations.media.Schema mergeSchemaAnnotations(
            io.swagger.v3.oas.annotations.media.Schema master,
            io.swagger.v3.oas.annotations.media.Schema patch); static io.swagger.v3.oas.annotations.media.ArraySchema mergeArraySchemaAnnotations(
            io.swagger.v3.oas.annotations.media.ArraySchema master,
            io.swagger.v3.oas.annotations.media.ArraySchema patch); static io.swagger.v3.oas.annotations.media.ArraySchema mergeArrayWithSchemaAnnotation(
            io.swagger.v3.oas.annotations.media.ArraySchema arraySchema,
            io.swagger.v3.oas.annotations.media.Schema schema); }
AnnotationsUtils { public static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation) { Class<?> schemaImplementation = annotationContent.schema().implementation(); boolean isArray = false; if (schemaImplementation == Void.class) { schemaImplementation = annotationContent.array().schema().implementation(); if (schemaImplementation != Void.class) { isArray = true; } } return getSchema(annotationContent.schema(), annotationContent.array(), isArray, schemaImplementation, components, jsonViewAnnotation); }  static boolean hasSchemaAnnotation(io.swagger.v3.oas.annotations.media.Schema schema); static boolean equals(Annotation thisAnnotation, Annotation thatAnnotation); static boolean equals(io.swagger.v3.oas.annotations.media.ArraySchema thisArraySchema, io.swagger.v3.oas.annotations.media.ArraySchema thatArraySchema); static boolean equals(io.swagger.v3.oas.annotations.media.Schema thisSchema, io.swagger.v3.oas.annotations.media.Schema thatSchema); static boolean hasArrayAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema array); static Optional<Example> getExample(ExampleObject example); static Optional<Example> getExample(ExampleObject example, boolean ignoreName); static Optional<ArraySchema> getArraySchema(io.swagger.v3.oas.annotations.media.ArraySchema arraySchema, JsonView jsonViewAnnotation); static Optional<ArraySchema> getArraySchema(io.swagger.v3.oas.annotations.media.ArraySchema arraySchema, Components components, JsonView jsonViewAnnotation); static Optional<Schema> getSchemaFromAnnotation(io.swagger.v3.oas.annotations.media.Schema schema, JsonView jsonViewAnnotation); static Optional<Schema> getSchemaFromAnnotation(io.swagger.v3.oas.annotations.media.Schema schema, Components components, JsonView jsonViewAnnotation); static Schema resolveSchemaFromType(Class<?> schemaImplementation, Components components, JsonView jsonViewAnnotation); static Optional<Set<Tag>> getTags(io.swagger.v3.oas.annotations.tags.Tag[] tags, boolean skipOnlyName); static Optional<List<Server>> getServers(io.swagger.v3.oas.annotations.servers.Server[] servers); static Optional<Server> getServer(io.swagger.v3.oas.annotations.servers.Server server); static Optional<ExternalDocumentation> getExternalDocumentation(io.swagger.v3.oas.annotations.ExternalDocumentation externalDocumentation); static Optional<Info> getInfo(io.swagger.v3.oas.annotations.info.Info info); static Optional<Contact> getContact(io.swagger.v3.oas.annotations.info.Contact contact); static Optional<License> getLicense(io.swagger.v3.oas.annotations.info.License license); static Map<String, Link> getLinks(io.swagger.v3.oas.annotations.links.Link[] links); static Optional<Link> getLink(io.swagger.v3.oas.annotations.links.Link link); static Map<String, String> getLinkParameters(LinkParameter[]
                                                                linkParameter); static Optional<Map<String, Header>> getHeaders(io.swagger.v3.oas.annotations.headers.Header[] annotationHeaders, JsonView jsonViewAnnotation); static Optional<Header> getHeader(io.swagger.v3.oas.annotations.headers.Header header, JsonView jsonViewAnnotation); static void addEncodingToMediaType(MediaType mediaType, io.swagger.v3.oas.annotations.media.Encoding encoding, JsonView jsonViewAnnotation); static Type getSchemaType(io.swagger.v3.oas.annotations.media.Schema schema); static Type getSchemaType(io.swagger.v3.oas.annotations.media.Schema schema, boolean nullIfNotFound); static Optional<Content> getContent(io.swagger.v3.oas.annotations.media.Content[] annotationContents, String[] classTypes, String[] methodTypes, Schema schema, Components components, JsonView jsonViewAnnotation); static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Content annotationContent, Components components, JsonView jsonViewAnnotation); static Optional<? extends Schema> getSchema(io.swagger.v3.oas.annotations.media.Schema schemaAnnotation,
                                                       io.swagger.v3.oas.annotations.media.ArraySchema arrayAnnotation,
                                                       boolean isArray,
                                                       Class<?> schemaImplementation,
                                                       Components components,
                                                       JsonView jsonViewAnnotation); static void applyTypes(String[] classTypes, String[] methodTypes, Content content, MediaType mediaType); static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Annotated a); static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Annotated a); static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Class<?> cls); static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Class<?> cls); static Map<String, Object> getExtensions(Extension... extensions); static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Annotation... annotations); static io.swagger.v3.oas.annotations.media.ArraySchema getArraySchemaAnnotation(Annotation... annotations); static T getAnnotation(Class<T> cls, Annotation... annotations); static Annotation[] removeAnnotations(Annotation[] annotations, Class ... classes); static void updateAnnotation(Class<?> clazz, io.swagger.v3.oas.annotations.media.Schema newAnnotation); static Annotation mergeSchemaAnnotations(
            Annotation[] ctxAnnotations, JavaType type); static io.swagger.v3.oas.annotations.media.Schema mergeSchemaAnnotations(
            io.swagger.v3.oas.annotations.media.Schema master,
            io.swagger.v3.oas.annotations.media.Schema patch); static io.swagger.v3.oas.annotations.media.ArraySchema mergeArraySchemaAnnotations(
            io.swagger.v3.oas.annotations.media.ArraySchema master,
            io.swagger.v3.oas.annotations.media.ArraySchema patch); static io.swagger.v3.oas.annotations.media.ArraySchema mergeArrayWithSchemaAnnotation(
            io.swagger.v3.oas.annotations.media.ArraySchema arraySchema,
            io.swagger.v3.oas.annotations.media.Schema schema); static final String COMPONENTS_REF; }