Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import io.swagger.v3.core.converter.ModelConverters;
import io.swagger.v3.core.converter.ResolvedSchema;
import io.swagger.v3.core.oas.models.ModelWithArrayOfSubclasses;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.core.util.Json31;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

import io.swagger.v3.core.util.ResourceUtils;
import org.testng.annotations.Test;

import java.nio.file.Files;
import java.nio.file.Paths;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;

Expand All @@ -21,7 +22,7 @@ public class ArrayOfSubclassTest {
public void extractSubclassArray_oas31() throws Exception {
ResolvedSchema schema = ModelConverters.getInstance(true).readAllAsResolvedSchema(ModelWithArrayOfSubclasses.Holder.class);
assertNotNull(schema);
String expectedJson = new String(Files.readAllBytes(Paths.get("src/test/resources/converting/ArrayOfSubclassTest_expected31.json")));
String expectedJson = ResourceUtils.loadClassResource(getClass(), "converting/ArrayOfSubclassTest_expected31.json");
String actualJson = Json31.pretty(schema);
ObjectMapper mapper = new ObjectMapper();
JsonNode expectedNode = mapper.readTree(expectedJson);
Expand All @@ -33,8 +34,8 @@ public void extractSubclassArray_oas31() throws Exception {
public void extractSubclassArray_oas30() throws Exception {
ResolvedSchema schema = ModelConverters.getInstance(false).readAllAsResolvedSchema(ModelWithArrayOfSubclasses.Holder.class);
assertNotNull(schema);
String expectedJson = new String(Files.readAllBytes(Paths.get("src/test/resources/converting/ArrayOfSubclassTest_expected30.json")));
String actualJson = Json31.pretty(schema);
String expectedJson = ResourceUtils.loadClassResource(getClass(), "converting/ArrayOfSubclassTest_expected30.json");
String actualJson = Json.pretty(schema);
ObjectMapper mapper = new ObjectMapper();
JsonNode expectedNode = mapper.readTree(expectedJson);
JsonNode actualNode = mapper.readTree(actualJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.core.converter.ModelConverterContextImpl;
import io.swagger.v3.core.converter.ModelConverters;
import io.swagger.v3.core.converter.ResolvedSchema;
import io.swagger.v3.core.jackson.ModelResolver;
import io.swagger.v3.core.util.Configuration;
import io.swagger.v3.core.util.Json;
Expand All @@ -10,6 +12,7 @@
import org.testng.annotations.Test;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;

import static org.testng.Assert.*;
Expand All @@ -18,11 +21,11 @@
* Reproduces GitHub Issue #5001
* Native support for @Nullable annotations to generate proper nullable types
*
* Tests that @Nullable annotation is recognized and generates appropriate nullable output:
* <p>Tests that @Nullable annotation is recognized and generates appropriate nullable output:
* - OAS 3.0: nullable keyword
* - OAS 3.1: type array with "null"
*
* Note: This test uses javax.annotation.Nullable which is automatically transformed to
* <p>Note: This test uses javax.annotation.Nullable which is automatically transformed to
* jakarta.annotation.Nullable in the swagger-core-jakarta module via the Eclipse Transformer.
*
* @see <a href="https://github.com/swagger-api/swagger-core/issues/5001">...</a>
Expand All @@ -33,7 +36,7 @@ public class Issue5001Test {
* Tests @Nullable annotation with OAS 3.1 (type array output)
*/
@Test
public void testNullableWithOAS31() throws Exception {
public void testNullableWithOAS31() {
final ModelResolver modelResolver = new ModelResolver(Json31.mapper());
Configuration configuration = new Configuration();
configuration.setOpenAPI31(true);
Expand Down Expand Up @@ -72,7 +75,7 @@ public void testNullableWithOAS31() throws Exception {
* Tests @Nullable annotation with OAS 3.0 (nullable keyword output)
*/
@Test
public void testNullableWithOAS30() throws Exception {
public void testNullableWithOAS30() {
final ModelResolver modelResolver = new ModelResolver(Json.mapper());
Configuration configuration = new Configuration();
configuration.setOpenAPI31(false);
Expand Down Expand Up @@ -103,7 +106,7 @@ public void testNullableWithOAS30() throws Exception {
* Tests explicit @Schema annotations with OAS 3.1
*/
@Test
public void testExplicitSchemaAnnotationsWithOAS31() throws Exception {
public void testExplicitSchemaAnnotationsWithOAS31() {
final ModelResolver modelResolver = new ModelResolver(Json31.mapper());
Configuration configuration = new Configuration();
configuration.setOpenAPI31(true);
Expand Down
Loading
Loading