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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ org-testcontainers = "1.21.4"
owasp-dependencycheck = "12.1.9"
protobuf = "4.33.2"
protobuf-plugin = "0.9.6"
spotless = "8.0.0"
spotless = "8.1.0"
spring-boot-plugin = "4.0.1"
spring-cloud = "2025.1.0" # not managed by spring-boot-dependencies
spring-cloud-stream = "5.0.0" # not managed by spring-boot-dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ void shouldSerializeGooglePubSubMessage() throws Exception {
.name("MessageProto")
.payload(MessagePayload.of(MultiFormatSchema.builder()
.schemaFormat("application/vnd.google.protobuf;version=3")
.schema(
"""
.schema("""
syntax = "proto3";

message Message {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ void shouldSerializePrimitiveSample() throws Exception {
var schema =
SchemaObject.builder().type(SchemaType.STRING).format("email").build();

String example =
"""
String example = """
{
"type": "string",
"format": "email"
Expand All @@ -45,8 +44,7 @@ void shouldSerializeSimpleModel() throws Exception {
.build()))
.build();

String example =
"""
String example = """
{
"type": "object",
"required": [
Expand Down Expand Up @@ -78,8 +76,7 @@ void shouldSerializeStringToStringMapping() throws Exception {
SchemaObject.builder().type(SchemaType.STRING).build()))
.build();

var example =
"""
var example = """
{
"type": "object",
"additionalProperties": {
Expand All @@ -97,8 +94,7 @@ void shouldSerializeModelMapping() throws Exception {
.additionalProperties(ComponentSchema.of(SchemaReference.toSchema("ComplexModel")))
.build();

var example =
"""
var example = """
{
"type": "object",
"additionalProperties": {
Expand All @@ -124,8 +120,7 @@ void shouldSerializeModelWithExample() throws Exception {
.examples(List.of(Map.of("name", "Puma", "id", 1)))
.build();

var example =
"""
var example = """
{
"type": "object",
"properties": {
Expand Down Expand Up @@ -161,8 +156,7 @@ void shouldSerializeModelWithBooleans() throws Exception {
.required(List.of("anySchema"))
.build();

var example =
"""
var example = """
{
"type": "object",
"required": [
Expand Down Expand Up @@ -213,8 +207,7 @@ void shouldSerializeModelsWithComposition() throws Exception {
.build())))
.build()));

var example =
"""
var example = """
{
"schemas": {
"ErrorModel": {
Expand Down Expand Up @@ -340,8 +333,7 @@ void shouldSerializeModelsWithPolimorphismSupport() throws Exception {
.required(List.of("color"))
.build())))
.build()));
var example =
"""
var example = """
{
"schemas": {
"Pet": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* @param simpleSchemaName
* @param schema The SchemaObject.
*/
public record PayloadSchemaObject(String name, String simpleSchemaName, @Nullable ComponentSchema schema) {
public record PayloadSchemaObject(
String name, String simpleSchemaName, @Nullable ComponentSchema schema) {
public String title() {
return (simpleSchemaName() != null) ? simpleSchemaName() : name();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public ComponentSchema mapSchema(Schema swaggerSchema) {
PayloadSchemaFormat payloadSchemaFormat =
springwolfConfigProperties.getDocket().getPayloadSchemaFormat();
return switch (payloadSchemaFormat) {
case OPENAPI_V3, OPENAPI_V3_1 -> ComponentSchema.of(
new MultiFormatSchema(payloadSchemaFormat.getSchemaFormat().value, swaggerSchema));
case OPENAPI_V3, OPENAPI_V3_1 ->
ComponentSchema.of(new MultiFormatSchema(payloadSchemaFormat.getSchemaFormat().value, swaggerSchema));
case ASYNCAPI_V3 -> ComponentSchema.of(mapSwaggerSchemaToAsyncApiSchema(swaggerSchema));
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ void getMessages() throws Exception {

String actualDefinitions =
jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(componentsService.getMessages());
String expected =
"""
String expected = """
{
"messageName1" : {
"name" : "messageName1"
},
"messageName2" : {
"name" : "messageName2"
}
}"""
.stripIndent();
}""".stripIndent();

System.out.println("Got: " + actualDefinitions);
assertThat(actualDefinitions).isEqualTo(expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ void getJsonTypeDefinitions() throws Exception {

@Schema(description = "Json Type Info Payload Dto model")
public record JsonTypeInfoPayloadDto(
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) JsonTypeInfoInterface jsonTypeInfoInterface) {}
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
JsonTypeInfoInterface jsonTypeInfoInterface) {}

@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type")
@JsonSubTypes({
Expand All @@ -337,20 +338,20 @@ public interface JsonTypeInfoInterface {}
@Schema(description = "Json Type Info Example Two model")
public record JsonTypeInfoExampleTwo(
@Schema(
description = "Boo field",
example = "booValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String boo)
description = "Boo field",
example = "booValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String boo)
implements JsonTypeInfoInterface {}

@JsonTypeName("exampleOne")
@Schema(description = "Json Type Info Example One model")
public record JsonTypeInfoExampleOne(
@Schema(
description = "Foo field",
example = "fooValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String foo)
description = "Foo field",
example = "fooValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String foo)
implements JsonTypeInfoInterface {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void getJsonTypeDefinitions() throws Exception {
@Schema(description = "Json Type Info Payload Dto model")
public record JsonTypeInfoPayloadDto(
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
JsonTypeTest.JsonTypeInfoInterface jsonTypeInfoInterface) {}
JsonTypeTest.JsonTypeInfoInterface jsonTypeInfoInterface) {}

@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type")
@JsonSubTypes({
Expand All @@ -343,20 +343,20 @@ public interface JsonTypeInfoInterface {}
@Schema(description = "Json Type Info Example Two model")
public record JsonTypeInfoExampleTwo(
@Schema(
description = "Boo field",
example = "booValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String boo)
description = "Boo field",
example = "booValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String boo)
implements JsonTypeInfoInterface {}

@JsonTypeName("exampleOne")
@Schema(description = "Json Type Info Example One model")
public record JsonTypeInfoExampleOne(
@Schema(
description = "Foo field",
example = "fooValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String foo)
description = "Foo field",
example = "fooValue",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String foo)
implements JsonTypeInfoInterface {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ void type_string_format_binary(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo(
"""
assertThat(actualString).isEqualTo("""
"0111010001100101011100110111010000101101011000100110100101101110011000010110010001111001"
""");
}
Expand All @@ -330,8 +328,7 @@ void type_string_format_datetime(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo("""
assertThat(actualString).isEqualTo("""
2015-07-20T15:49:04-07:00
""");
}
Expand Down Expand Up @@ -367,8 +364,7 @@ void type_string_format_uuid(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo("""
assertThat(actualString).isEqualTo("""
3fa85f64-5717-4562-b3fc-2c963f66afa6
""");
}
Expand All @@ -381,8 +377,7 @@ void type_string_format_unknown(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo("""
assertThat(actualString).isEqualTo("""
"unknown string schema format: unknown"
""");
}
Expand All @@ -400,8 +395,7 @@ class TestSchema extends Schema<StringSchema> {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo("""
assertThat(actualString).isEqualTo("""
"unknown schema type: test-schema"
""");
}
Expand Down Expand Up @@ -434,9 +428,7 @@ void type_object_array(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo(
"""
assertThat(actualString).isEqualTo("""
- b: true
s: string
""");
Expand All @@ -451,8 +443,7 @@ void composite_object_without_references(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap());

assertThat(actualString)
.isEqualTo("""
assertThat(actualString).isEqualTo("""
b: true
s: string
""");
Expand All @@ -473,9 +464,7 @@ void composite_object_with_references(TestInfo testInfo) {
nestedSchema.addProperty("b", new BooleanSchema());
String actualString = jsonSchemaWalker.fromSchema(compositeSchema, Map.of("Nested", nestedSchema));

assertThat(actualString)
.isEqualTo(
"""
assertThat(actualString).isEqualTo("""
f:
b: true
s: string
Expand Down Expand Up @@ -532,9 +521,7 @@ void object_with_allOf(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(compositeSchema, Map.of("Nested", propertySchema));

assertThat(actualString)
.isEqualTo(
"""
assertThat(actualString).isEqualTo("""
allOfField:
field1: string
field2: 1.1
Expand Down Expand Up @@ -581,9 +568,7 @@ void schema_with_problematic_object_toString_example(TestInfo testInfo) {

String actualString = jsonSchemaWalker.fromSchema(schema, Map.of());

assertThat(actualString)
.isEqualTo(
"""
assertThat(actualString).isEqualTo("""
Text with special character /\\\\'\\b\\f\\t\\r\\n.
""");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ void textWithSingleIndentShouldBeUntouched() {

@Test
void removeIndent() {
var description =
"""
var description = """
This is a string
with two lines
""";
Expand All @@ -54,8 +53,7 @@ void simpleTextWithoutIndentShouldBeUntouched() {

@Test
void removeEmptyLinesUntilTextIsFound() {
var description =
"""
var description = """

This is a string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@

import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

@Schema(
description =
"""
@Schema(description = """
Example payload model demonstrating markdown text styling:
**bold**, *cursive* and <u>underlined</u>
""")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExamplePayloadDto {
@Schema(
description =
"""
@Schema(description = """
### Some string field with Markdown

- **bold**
Expand All @@ -34,9 +30,7 @@ public class ExamplePayloadDto {
"key2":"value2"
}
```
""",
example = "some string value",
requiredMode = REQUIRED)
""", example = "some string value", requiredMode = REQUIRED)
private String someString;

@Schema(description = "Some long field", example = "5", minimum = "0")
Expand Down
Loading
Loading