Skip to content

Update to Jackson 2.11.0 #3576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ public void deserializeDateExample() throws IOException {
final OpenAPI swagger = Yaml.mapper().readValue(jsonString, OpenAPI.class);
assertNotNull(swagger);
Map<String, Schema> props = swagger.getComponents().getSchemas().get("MyModel").getProperties();
assertTrue(Yaml.pretty().writeValueAsString(props.get("date")).contains("example: 2019-08-05"));
assertTrue(Yaml.pretty().writeValueAsString(props.get("dateTime")).contains("example: 2019-08-05T12:34:56Z"));
final String dateYaml = Yaml.mapper().writeValueAsString(props.get("date"));
assertEquals(Yaml.mapper().readTree(dateYaml).path("example").asText(), "2019-08-05");
final String dateTimeYaml = Yaml.mapper().writeValueAsString(props.get("dateTime"));
assertEquals(Yaml.mapper().readTree(dateTimeYaml).path("example").asText(), "2019-08-05T12:34:56Z");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void compareAsYaml(final Class<?> cls, final String yaml) throws IOExcept
}

public void compareAsYaml(final String actualYaml, final String expectedYaml) throws IOException {
SerializationMatchers.assertEqualsToYaml(Yaml.mapper().readValue(actualYaml, OpenAPI.class), expectedYaml);
SerializationMatchers.assertEqualsToYaml(Yaml.mapper().readValue(actualYaml, JsonNode.class), expectedYaml);
}

public void compareAsJson(final String actualJson, final String expectedJson) throws IOException {
SerializationMatchers.assertEqualsToJson(Yaml.mapper().readValue(actualJson, OpenAPI.class), expectedJson);
SerializationMatchers.assertEqualsToJson(Yaml.mapper().readValue(actualJson, JsonNode.class), expectedJson);
}

protected String getOpenAPIAsString(final String file) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;

import java.io.IOException;

import static org.testng.Assert.assertEquals;

public class CallbackTest extends AbstractAnnotationTest {
@Test
public void testSimpleCallback() {
public void testSimpleCallback() throws IOException {
String openApiYAML = readIntoYaml(SimpleCallback.class);
int start = openApiYAML.indexOf("/test:");
int end = openApiYAML.length() - 1;
Expand Down Expand Up @@ -85,7 +87,7 @@ public void testSimpleCallback() {
" properties:\n" +
" subscriptionId:\n" +
" type: string";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

static class SimpleCallback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import javax.ws.rs.POST;
import javax.ws.rs.Path;

import java.io.IOException;

import static org.testng.Assert.assertEquals;

public class ExamplesTest extends AbstractAnnotationTest {
Expand Down Expand Up @@ -342,7 +344,7 @@ public ExamplesTest.AnnotatedSubscription testAnnotatedModel(


@Test
public void testFullExample() {
public void testFullExample() throws IOException {
String openApiYAML = readIntoYaml(ExamplesTest.SimpleOperations.class);
int start = openApiYAML.indexOf("/test:");
int end = openApiYAML.length() - 1;
Expand Down Expand Up @@ -437,7 +439,7 @@ public void testFullExample() {
" format: int32\n" +
" xml:\n" +
" name: User";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

static class SimpleOperations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import io.swagger.v3.oas.annotations.info.License;
import org.testng.annotations.Test;

import java.io.IOException;

import static org.testng.Assert.assertEquals;

public class InfoTest extends AbstractAnnotationTest {
@Test
public void testSimpleInfoGet() {
public void testSimpleInfoGet() throws IOException {
String openApiYAML = readIntoYaml(InfoTest.ClassWithInfoAnnotation.class);
int start = openApiYAML.indexOf("info:");
int end = openApiYAML.length() - 1;
Expand All @@ -29,7 +31,7 @@ public void testSimpleInfoGet() {
" version: \"0.0\"";
String extractedYAML = openApiYAML.substring(start, end);

assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

@OpenAPIDefinition(info = @Info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void simpleGet() {
}

@Test
public void testGetOperationWithResponsePayloadAndAlternateCodes() {
public void testGetOperationWithResponsePayloadAndAlternateCodes() throws IOException {
String openApiYAML = readIntoYaml(GetOperationWithResponsePayloadAndAlternateCodes.class);
int start = openApiYAML.indexOf("get:");
int end = openApiYAML.indexOf("components:");
Expand Down Expand Up @@ -128,7 +128,7 @@ public void testGetOperationWithResponsePayloadAndAlternateCodes() {
" externalValue: example of external value\n" +
" deprecated: true\n";

assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

static class GetOperationWithResponsePayloadAndAlternateCodes {
Expand Down Expand Up @@ -177,7 +177,7 @@ static class GenericError {
}

@Test(description = "reads an operation with response examples defined")
public void testOperationWithResponseExamples() {
public void testOperationWithResponseExamples() throws IOException {
String openApiYAML = readIntoYaml(GetOperationWithResponseExamples.class);
int start = openApiYAML.indexOf("get:");
int end = openApiYAML.indexOf("components:");
Expand All @@ -199,11 +199,11 @@ public void testOperationWithResponseExamples() {
" description: basic\n" +
" value: '{id: 19877734}'\n" +
" deprecated: true\n";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

@Test(description = "reads an operation with response examples defined")
public void testOperationWithParameterExample() {
public void testOperationWithParameterExample() throws IOException {
String openApiYAML = readIntoYaml(GetOperationWithParameterExample.class);
int start = openApiYAML.indexOf("get:");
int end = openApiYAML.indexOf("components:");
Expand Down Expand Up @@ -231,7 +231,7 @@ public void testOperationWithParameterExample() {
" description: basic\n" +
" value: '{id: 19877734}'\n" +
" deprecated: true\n";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

static class GetOperationWithResponseExamples {
Expand Down Expand Up @@ -1055,7 +1055,7 @@ public void testHiddenAnnotatedUserResource() throws IOException {
}

@Test
public void testSimpleGetOperationWithSecurity() {
public void testSimpleGetOperationWithSecurity() throws IOException {

String openApiYAML = readIntoYaml(SimpleGetOperationWithSecurity.class);
int start = openApiYAML.indexOf("get:");
Expand All @@ -1073,7 +1073,7 @@ public void testSimpleGetOperationWithSecurity() {
" - write:pets";
String extractedYAML = openApiYAML.substring(start, end);

assertEquals(expectedYAML, extractedYAML);
compareAsYaml(expectedYAML, extractedYAML);
}

static class SimpleGetOperationWithSecurity {
Expand All @@ -1096,7 +1096,7 @@ public void simpleGet() {
}

@Test
public void testSimpleGetOperationWithMultipleSecurity() {
public void testSimpleGetOperationWithMultipleSecurity() throws IOException {

String openApiYAML = readIntoYaml(SimpleGetOperationWithMultipleSecurityScopes.class);
int start = openApiYAML.indexOf("get:");
Expand All @@ -1115,7 +1115,7 @@ public void testSimpleGetOperationWithMultipleSecurity() {
" - read:pets";
String extractedYAML = openApiYAML.substring(start, end);

assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

static class SimpleGetOperationWithMultipleSecurityScopes {
Expand All @@ -1138,7 +1138,7 @@ public void simpleGet() {
}

@Test
public void testSimpleGetOperationWithMultipleSecurityAnnotations() {
public void testSimpleGetOperationWithMultipleSecurityAnnotations() throws IOException {

String openApiYAML = readIntoYaml(SimpleGetOperationWithMultipleSecurityAnnotations.class);
int start = openApiYAML.indexOf("get:");
Expand All @@ -1160,7 +1160,7 @@ public void testSimpleGetOperationWithMultipleSecurityAnnotations() {
" - api_key: []";
String extractedYAML = openApiYAML.substring(start, end);

assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

static class SimpleGetOperationWithMultipleSecurityAnnotations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;

import java.io.IOException;

import static org.testng.Assert.assertEquals;

public class MergedOperationTest extends AbstractAnnotationTest {
Expand All @@ -34,10 +36,10 @@ static class SimpleResponse {
}

@Test(description = "shows how a method with parameters and no special annotations is processed")
public void testAnnotatedParameters() {
public void testAnnotatedParameters() throws IOException {
String yaml = readIntoYaml(MethodWithParameters.class);

assertEquals(yaml,
compareAsYaml(yaml,
"openapi: 3.0.1\n" +
"paths:\n" +
" /findAll:\n" +
Expand Down Expand Up @@ -80,7 +82,7 @@ public SimpleResponse getSimpleResponseWithParameters(
}

@Test(description = "shows how annotations can decorate an operation")
public void testPartiallyAnnotatedMethod() {
public void testPartiallyAnnotatedMethod() throws IOException {
String yaml = readIntoYaml(MethodWithPartialAnnotation.class);
String expectedYaml = "openapi: 3.0.1\n" +
"paths:\n" +
Expand Down Expand Up @@ -114,7 +116,7 @@ public void testPartiallyAnnotatedMethod() {
" SimpleResponse:\n" +
" type: object\n";

assertEquals(yaml, expectedYaml);
compareAsYaml(yaml, expectedYaml);
}

static class MethodWithPartialAnnotation {
Expand All @@ -134,7 +136,7 @@ public SimpleResponse getSimpleResponseWithParameters(
}

@Test(description = "shows how a request body is passed")
public void testRequestBody() {
public void testRequestBody() throws IOException {
String yaml = readIntoYaml(MethodWithRequestBody.class);
String expectedYaml = "openapi: 3.0.1\n" +
"paths:\n" +
Expand All @@ -155,7 +157,7 @@ public void testRequestBody() {
" InputValue:\n" +
" type: object\n";

assertEquals(yaml, expectedYaml);
compareAsYaml(yaml, expectedYaml);
}

static class MethodWithRequestBody {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -41,7 +42,7 @@ public void scanClassAndFieldLevelAnnotations() {
}

@Test
public void testParameters() {
public void testParameters() throws IOException {
String openApiYAML = readIntoYaml(ParametersTest.SimpleOperations.class);
int start = openApiYAML.indexOf("/test:");
int end = openApiYAML.length() - 1;
Expand Down Expand Up @@ -129,11 +130,11 @@ public void testParameters() {
" properties:\n" +
" subscriptionId:\n" +
" type: string";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

@Test
public void testArraySchemaParameters() {
public void testArraySchemaParameters() throws IOException {
String openApiYAML = readIntoYaml(ParametersTest.ArraySchemaOperations.class);
int start = openApiYAML.indexOf("/test:");
int end = openApiYAML.length() - 1;
Expand Down Expand Up @@ -169,11 +170,11 @@ public void testArraySchemaParameters() {
" properties:\n" +
" subscriptionId:\n" +
" type: string";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

@Test
public void testRepeatableParameters() {
public void testRepeatableParameters() throws IOException {
String openApiYAML = readIntoYaml(ParametersTest.RepeatableParametersOperations.class);
int start = openApiYAML.indexOf("/test:");
int end = openApiYAML.length() - 1;
Expand Down Expand Up @@ -261,7 +262,7 @@ public void testRepeatableParameters() {
" properties:\n" +
" subscriptionId:\n" +
" type: string";
assertEquals(extractedYAML, expectedYAML);
compareAsYaml(extractedYAML, expectedYAML);
}

@Test(description = "JsonUnwrapped, JsonIgnore, JsonValue should be honoured")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void setZip(String zip) {
}

@Test(description = "Shows creating simple links")
public void createOperationWithLinkReferences() {
public void createOperationWithLinkReferences() throws IOException {
String openApiYAML = readIntoYaml(ClassWithOperationAndLinkReferences.class);
int start = openApiYAML.indexOf("/users:");
int end = openApiYAML.length() - 1;
Expand Down Expand Up @@ -327,7 +327,7 @@ public void createOperationWithLinkReferences() {
" username:\n" +
" type: string";
String extractedYAML = openApiYAML.substring(start, end);
assertEquals(extractedYAML, expectedYaml);
compareAsYaml(extractedYAML, expectedYaml);
}

static class ClassWithOperationAndLinkReferences {
Expand Down
Loading