Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Looks like something has changed in Jackson that means the def references are in double quotes, not single quotes.
  • Loading branch information
big-andy-coates committed Jun 22, 2024
1 parent 82b7a33 commit 329720a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
Expand Down Expand Up @@ -92,6 +93,7 @@ class SchemaGeneratorTest {
.addModule(new JavaTimeModule())
.serializationInclusion(JsonInclude.Include.NON_EMPTY)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
.build();
private final ObjectMapper yamlMapper =
new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.MINIMIZE_QUOTES));
Expand Down Expand Up @@ -371,9 +373,9 @@ void shouldIncludeExplicitSubTypesRegardlessOfFilters() {
""
+ "oneOf:"
+ lineSeparator()
+ "- $ref: '#/definitions/ExplicitlyNamed'"
+ "- $ref: \"#/definitions/ExplicitlyNamed\""
+ lineSeparator()
+ "- $ref: '#/definitions/ImplicitlyNamed'"));
+ "- $ref: \"#/definitions/ImplicitlyNamed\""));

assertThat(result.text(), containsString("default: " + explicitType));
assertThat(result.text(), containsString("default: " + implicitType));
Expand Down Expand Up @@ -409,11 +411,11 @@ void shouldIncludeImplicitSubTypesUsingTypeName() {
""
+ "oneOf:"
+ lineSeparator()
+ "- $ref: '#/definitions/ImplicitlyNamed'"
+ "- $ref: \"#/definitions/ImplicitlyNamed\""
+ lineSeparator()
+ "- $ref: '#/definitions/"
+ "- $ref: \"#/definitions/"
+ explicitType
+ "'"));
+ "\""));

assertThat(result.text(), containsString("default: " + explicitType));
assertThat(result.text(), containsString("default: " + implicitType));
Expand Down Expand Up @@ -447,11 +449,11 @@ void shouldIncludeImplicitSubTypesUsingSimpleName() {
""
+ "oneOf:"
+ lineSeparator()
+ "- $ref: '#/definitions/"
+ "- $ref: \"#/definitions/"
+ explicitType
+ "'"
+ "\""
+ lineSeparator()
+ "- $ref: '#/definitions/ImplicitlyNamed'"));
+ "- $ref: \"#/definitions/ImplicitlyNamed\""));

assertThat(result.text(), containsString("default: " + explicitType));
assertThat(result.text(), containsString("default: " + implicitType));
Expand All @@ -478,9 +480,9 @@ void shouldIncludeImplicitSubTypesUsingClass() {
containsString(
"oneOf:"
+ lineSeparator()
+ "- $ref: '#/definitions/the-explicit-name'"
+ "- $ref: \"#/definitions/the-explicit-name\""
+ lineSeparator()
+ "- $ref: '#/definitions/ImplicitlyNamed'"));
+ "- $ref: \"#/definitions/ImplicitlyNamed\""));

assertThat(result.text(), containsString("default: " + explicitClass));
assertThat(result.text(), containsString("default: " + implicitClass));
Expand All @@ -507,9 +509,9 @@ void shouldIncludeImplicitSubTypesUsingMinimalClass() {
containsString(
"oneOf:"
+ lineSeparator()
+ "- $ref: '#/definitions/the-explicit-name'"
+ "- $ref: \"#/definitions/the-explicit-name\""
+ lineSeparator()
+ "- $ref: '#/definitions/ImplicitlyNamed'"));
+ "- $ref: \"#/definitions/ImplicitlyNamed\""));

assertThat(result.text(), containsString("default: " + explicitClass));
assertThat(result.text(), containsString("default: " + implicitClass));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
$schema: http://json-schema.org/draft-07/schema#
title: Thing
oneOf:
- $ref: '#/definitions/SmallThing'
- $ref: '#/definitions/big'
- $ref: "#/definitions/SmallThing"
- $ref: "#/definitions/big"
definitions:
SmallThing:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
$schema: http://json-schema.org/draft-07/schema#
title: Polymorphic Model
oneOf:
- $ref: '#/definitions/SubType1'
- $ref: '#/definitions/SubType2'
- $ref: "#/definitions/SubType1"
- $ref: "#/definitions/SubType2"
definitions:
SubType1:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
$schema: http://json-schema.org/draft-07/schema#
title: Thing
oneOf:
- $ref: '#/definitions/SmallThing'
- $ref: '#/definitions/big'
- $ref: "#/definitions/SmallThing"
- $ref: "#/definitions/big"
definitions:
SmallThing:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
$schema: http://json-schema.org/draft-07/schema#
title: Polymorphic Model
oneOf:
- $ref: '#/definitions/SubType1'
- $ref: '#/definitions/SubType2'
- $ref: "#/definitions/SubType1"
- $ref: "#/definitions/SubType2"
definitions:
SubType1:
type: object
Expand Down

0 comments on commit 329720a

Please sign in to comment.