Skip to content

Commit e54cf32

Browse files
committed
syntax improvment. Fixes #891
1 parent 182e7c2 commit e54cf32

File tree

39 files changed

+580
-587
lines changed

39 files changed

+580
-587
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/fn/AbstractSpringdocRouteBuilder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525

2626
import java.util.function.Consumer;
2727

28-
import org.springdoc.core.fn.builders.OperationBuilder;
28+
import org.springdoc.core.fn.builders.operation.Builder;
2929

3030
/**
3131
* @author bnasslahsen
3232
*/
3333
public abstract class AbstractSpringdocRouteBuilder {
3434

35-
protected OperationBuilder getOperationBuilder(Consumer<OperationBuilder> operationsConsumer) {
36-
OperationBuilder builder = OperationBuilder.builder();
35+
protected Builder getOperationBuilder(Consumer<Builder> operationsConsumer) {
36+
Builder builder = Builder.operation();
3737
operationsConsumer.accept(builder);
3838
return builder;
3939
}

springdoc-openapi-common/src/main/java/org/springdoc/core/fn/RouterOperation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io.swagger.v3.oas.annotations.Operation;
2828
import org.apache.commons.lang3.ArrayUtils;
2929
import org.apache.commons.lang3.StringUtils;
30-
import org.springdoc.core.fn.builders.OperationBuilder;
30+
import org.springdoc.core.fn.builders.operation.Builder;
3131

3232
import org.springframework.web.bind.annotation.RequestMethod;
3333

@@ -161,7 +161,7 @@ public RouterOperation(RouterFunctionData routerFunctionData) {
161161

162162
Map<String, Object> attributes = routerFunctionData.getAttributes();
163163
if (attributes.containsKey(OPERATION_ATTRIBUTE)) {
164-
OperationBuilder routerOperationBuilder = (OperationBuilder) attributes.get(OPERATION_ATTRIBUTE);
164+
Builder routerOperationBuilder = (Builder) attributes.get(OPERATION_ATTRIBUTE);
165165
RouterOperation routerOperation = routerOperationBuilder.build();
166166
this.beanClass = routerOperation.getBeanClass();
167167
this.beanMethod = routerOperation.getBeanMethod();

springdoc-openapi-common/src/main/java/org/springdoc/core/fn/builders/ApiResponseBuilder.java renamed to springdoc-openapi-common/src/main/java/org/springdoc/core/fn/builders/apiresponse/Builder.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*/
2323

24-
package org.springdoc.core.fn.builders;
24+
package org.springdoc.core.fn.builders.apiresponse;
2525

2626
import java.lang.annotation.Annotation;
2727

@@ -36,7 +36,7 @@
3636
* The type Api response builder.
3737
* @author bnasslahsen
3838
*/
39-
public class ApiResponseBuilder {
39+
public class Builder {
4040

4141
/**
4242
* A short description of the response.
@@ -85,16 +85,16 @@ public class ApiResponseBuilder {
8585
/**
8686
* Instantiates a new Api response builder.
8787
*/
88-
private ApiResponseBuilder() {
88+
private Builder() {
8989
}
9090

9191
/**
9292
* Builder api response builder.
9393
*
9494
* @return the api response builder
9595
*/
96-
public static ApiResponseBuilder builder() {
97-
return new ApiResponseBuilder();
96+
public static Builder apiResponse() {
97+
return new Builder();
9898
}
9999

100100
/**
@@ -103,7 +103,7 @@ public static ApiResponseBuilder builder() {
103103
* @param description the description
104104
* @return the api response builder
105105
*/
106-
public ApiResponseBuilder description(String description) {
106+
public Builder description(String description) {
107107
this.description = description;
108108
return this;
109109
}
@@ -114,7 +114,7 @@ public ApiResponseBuilder description(String description) {
114114
* @param responseCode the response code
115115
* @return the api response builder
116116
*/
117-
public ApiResponseBuilder responseCode(String responseCode) {
117+
public Builder responseCode(String responseCode) {
118118
this.responseCode = responseCode;
119119
return this;
120120
}
@@ -125,7 +125,7 @@ public ApiResponseBuilder responseCode(String responseCode) {
125125
* @param headers the headers
126126
* @return the api response builder
127127
*/
128-
public ApiResponseBuilder header(HeaderBuilder headers) {
128+
public Builder header(org.springdoc.core.fn.builders.header.Builder headers) {
129129
this.headers = ArrayUtils.add(this.headers, headers.build());
130130
return this;
131131
}
@@ -136,7 +136,7 @@ public ApiResponseBuilder header(HeaderBuilder headers) {
136136
* @param linkBuilder the link builder
137137
* @return the api response builder
138138
*/
139-
public ApiResponseBuilder link(LinkBuilder linkBuilder) {
139+
public Builder link(org.springdoc.core.fn.builders.link.Builder linkBuilder) {
140140
this.links = ArrayUtils.add(this.links, linkBuilder.build());
141141
return this;
142142
}
@@ -147,7 +147,7 @@ public ApiResponseBuilder link(LinkBuilder linkBuilder) {
147147
* @param contentBuilder the content builder
148148
* @return the api response builder
149149
*/
150-
public ApiResponseBuilder content(ContentBuilder contentBuilder) {
150+
public Builder content(org.springdoc.core.fn.builders.content.Builder contentBuilder) {
151151
this.content = ArrayUtils.add(this.content, contentBuilder.build());
152152
return this;
153153
}
@@ -158,8 +158,8 @@ public ApiResponseBuilder content(ContentBuilder contentBuilder) {
158158
* @param clazz the clazz
159159
* @return the api response builder
160160
*/
161-
public ApiResponseBuilder implementation(Class clazz) {
162-
this.content = ArrayUtils.add(this.content, ContentBuilder.builder().schema(SchemaBuilder.builder().implementation(clazz)).build());
161+
public Builder implementation(Class clazz) {
162+
this.content = ArrayUtils.add(this.content, org.springdoc.core.fn.builders.content.Builder.content().schema(org.springdoc.core.fn.builders.schema.Builder.schema().implementation(clazz)).build());
163163
return this;
164164
}
165165

@@ -169,8 +169,8 @@ public ApiResponseBuilder implementation(Class clazz) {
169169
* @param clazz the clazz
170170
* @return the api response builder
171171
*/
172-
public ApiResponseBuilder implementationArray(Class clazz) {
173-
this.content = ArrayUtils.add(this.content, ContentBuilder.builder().array(ArraySchemaBuilder.builder().schema(SchemaBuilder.builder().implementation(clazz))).build());
172+
public Builder implementationArray(Class clazz) {
173+
this.content = ArrayUtils.add(this.content, org.springdoc.core.fn.builders.content.Builder.content().array(org.springdoc.core.fn.builders.arrayschema.Builder.arraySchema().schema(org.springdoc.core.fn.builders.schema.Builder.schema().implementation(clazz))).build());
174174
return this;
175175
}
176176

@@ -180,7 +180,7 @@ public ApiResponseBuilder implementationArray(Class clazz) {
180180
* @param extensionBuilder the extension builder
181181
* @return the api response builder
182182
*/
183-
public ApiResponseBuilder extension(ExtensionBuilder extensionBuilder) {
183+
public Builder extension(org.springdoc.core.fn.builders.extension.Builder extensionBuilder) {
184184
this.extensions = ArrayUtils.add(this.extensions, extensionBuilder.build());
185185
return this;
186186
}
@@ -191,7 +191,7 @@ public ApiResponseBuilder extension(ExtensionBuilder extensionBuilder) {
191191
* @param ref the ref
192192
* @return the api response builder
193193
*/
194-
public ApiResponseBuilder ref(String ref) {
194+
public Builder ref(String ref) {
195195
this.ref = ref;
196196
return this;
197197
}

springdoc-openapi-common/src/main/java/org/springdoc/core/fn/builders/ArraySchemaBuilder.java renamed to springdoc-openapi-common/src/main/java/org/springdoc/core/fn/builders/arrayschema/Builder.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*/
2323

24-
package org.springdoc.core.fn.builders;
24+
package org.springdoc.core.fn.builders.arrayschema;
2525

2626
import java.lang.annotation.Annotation;
2727

@@ -34,19 +34,19 @@
3434
* The type Array schema builder.
3535
* @author bnasslahsen
3636
*/
37-
public class ArraySchemaBuilder {
37+
public class Builder {
3838
/**
3939
* The schema of the items in the array
4040
*
4141
*/
42-
private Schema schema = SchemaBuilder.builder().build();
42+
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
4343

4444
/**
4545
* Allows to define the properties to be resolved into properties of the schema of type `array` (not the ones of the
4646
* `items` of such schema which are defined in schema}.
4747
*
4848
*/
49-
private Schema arraySchema = SchemaBuilder.builder().build();
49+
private Schema arraySchema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
5050

5151
/**
5252
* sets the maximum number of items in an array. Ignored if value is Integer.MIN_VALUE.
@@ -76,16 +76,16 @@ public class ArraySchemaBuilder {
7676
/**
7777
* Instantiates a new Array schema builder.
7878
*/
79-
private ArraySchemaBuilder() {
79+
private Builder() {
8080
}
8181

8282
/**
8383
* Builder array schema builder.
8484
*
8585
* @return the array schema builder
8686
*/
87-
public static ArraySchemaBuilder builder() {
88-
return new ArraySchemaBuilder();
87+
public static Builder arraySchema() {
88+
return new Builder();
8989
}
9090

9191
/**
@@ -94,7 +94,7 @@ public static ArraySchemaBuilder builder() {
9494
* @param schemaBuilder the schema builder
9595
* @return the array schema builder
9696
*/
97-
public ArraySchemaBuilder schema(SchemaBuilder schemaBuilder) {
97+
public Builder schema(org.springdoc.core.fn.builders.schema.Builder schemaBuilder) {
9898
this.schema = schemaBuilder.build();
9999
return this;
100100
}
@@ -105,7 +105,7 @@ public ArraySchemaBuilder schema(SchemaBuilder schemaBuilder) {
105105
* @param schemaBuilder the schema builder
106106
* @return the array schema builder
107107
*/
108-
public ArraySchemaBuilder arraySchema(SchemaBuilder schemaBuilder) {
108+
public Builder arraySchema(org.springdoc.core.fn.builders.schema.Builder schemaBuilder) {
109109
this.arraySchema = schemaBuilder.build();
110110
return this;
111111
}
@@ -116,7 +116,7 @@ public ArraySchemaBuilder arraySchema(SchemaBuilder schemaBuilder) {
116116
* @param maxItems the max items
117117
* @return the array schema builder
118118
*/
119-
public ArraySchemaBuilder maxItems(int maxItems) {
119+
public Builder maxItems(int maxItems) {
120120
this.maxItems = maxItems;
121121
return this;
122122
}
@@ -127,7 +127,7 @@ public ArraySchemaBuilder maxItems(int maxItems) {
127127
* @param minItems the min items
128128
* @return the array schema builder
129129
*/
130-
public ArraySchemaBuilder minItems(int minItems) {
130+
public Builder minItems(int minItems) {
131131
this.minItems = minItems;
132132
return this;
133133
}
@@ -138,7 +138,7 @@ public ArraySchemaBuilder minItems(int minItems) {
138138
* @param uniqueItems the unique items
139139
* @return the array schema builder
140140
*/
141-
public ArraySchemaBuilder uniqueItems(boolean uniqueItems) {
141+
public Builder uniqueItems(boolean uniqueItems) {
142142
this.uniqueItems = uniqueItems;
143143
return this;
144144
}
@@ -149,7 +149,7 @@ public ArraySchemaBuilder uniqueItems(boolean uniqueItems) {
149149
* @param extensionBuilder the extension builder
150150
* @return the array schema builder
151151
*/
152-
public ArraySchemaBuilder extension(ExtensionBuilder extensionBuilder) {
152+
public Builder extension(org.springdoc.core.fn.builders.extension.Builder extensionBuilder) {
153153
this.extensions = ArrayUtils.add( this.extensions, extensionBuilder.build());
154154
return this;
155155
}

springdoc-openapi-common/src/main/java/org/springdoc/core/fn/builders/ContentBuilder.java renamed to springdoc-openapi-common/src/main/java/org/springdoc/core/fn/builders/content/Builder.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*/
2323

24-
package org.springdoc.core.fn.builders;
24+
package org.springdoc.core.fn.builders.content;
2525

2626
import java.lang.annotation.Annotation;
2727

@@ -37,7 +37,7 @@
3737
* The type Content builder.
3838
* @author bnasslahsen
3939
*/
40-
public class ContentBuilder {
40+
public class Builder {
4141

4242
/**
4343
* The media type that this object applies to.
@@ -55,13 +55,13 @@ public class ContentBuilder {
5555
* The schema defining the type used for the content.
5656
*
5757
*/
58-
private Schema schema = SchemaBuilder.builder().build();
58+
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
5959

6060
/**
6161
* The schema of the array that defines the type used for the content.
6262
*
6363
*/
64-
private ArraySchema array = ArraySchemaBuilder.builder().build();
64+
private ArraySchema array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchema().build();
6565

6666
/**
6767
* An array of encodings
@@ -80,16 +80,16 @@ public class ContentBuilder {
8080
/**
8181
* Instantiates a new Content builder.
8282
*/
83-
private ContentBuilder() {
83+
private Builder() {
8484
}
8585

8686
/**
8787
* Builder content builder.
8888
*
8989
* @return the content builder
9090
*/
91-
public static ContentBuilder builder() {
92-
return new ContentBuilder();
91+
public static Builder content() {
92+
return new Builder();
9393
}
9494

9595
/**
@@ -98,7 +98,7 @@ public static ContentBuilder builder() {
9898
* @param mediaType the media type
9999
* @return the content builder
100100
*/
101-
public ContentBuilder mediaType(String mediaType) {
101+
public Builder mediaType(String mediaType) {
102102
this.mediaType = mediaType;
103103
return this;
104104
}
@@ -109,7 +109,7 @@ public ContentBuilder mediaType(String mediaType) {
109109
* @param exampleObjectBuilder the example object builder
110110
* @return the content builder
111111
*/
112-
public ContentBuilder example(ExampleObjectBuilder exampleObjectBuilder) {
112+
public Builder example(org.springdoc.core.fn.builders.exampleobject.Builder exampleObjectBuilder) {
113113
this.examples = ArrayUtils.add( this.examples, exampleObjectBuilder.build());
114114
return this;
115115
}
@@ -120,7 +120,7 @@ public ContentBuilder example(ExampleObjectBuilder exampleObjectBuilder) {
120120
* @param schemaBuilder the schema builder
121121
* @return the content builder
122122
*/
123-
public ContentBuilder schema(SchemaBuilder schemaBuilder) {
123+
public Builder schema(org.springdoc.core.fn.builders.schema.Builder schemaBuilder) {
124124
this.schema = schemaBuilder.build();
125125
return this;
126126
}
@@ -131,7 +131,7 @@ public ContentBuilder schema(SchemaBuilder schemaBuilder) {
131131
* @param arraySchemaBuilder the array schema builder
132132
* @return the content builder
133133
*/
134-
public ContentBuilder array(ArraySchemaBuilder arraySchemaBuilder) {
134+
public Builder array(org.springdoc.core.fn.builders.arrayschema.Builder arraySchemaBuilder) {
135135
this.array = arraySchemaBuilder.build();
136136
return this;
137137
}
@@ -142,7 +142,7 @@ public ContentBuilder array(ArraySchemaBuilder arraySchemaBuilder) {
142142
* @param encodingBuilder the encoding builder
143143
* @return the content builder
144144
*/
145-
public ContentBuilder encoding(EncodingBuilder encodingBuilder) {
145+
public Builder encoding(org.springdoc.core.fn.builders.encoding.Builder encodingBuilder) {
146146
this.encodings = ArrayUtils.add( this.encodings, encodingBuilder.build());
147147
return this;
148148
}
@@ -153,7 +153,7 @@ public ContentBuilder encoding(EncodingBuilder encodingBuilder) {
153153
* @param extensionBuilder the extension builder
154154
* @return the content builder
155155
*/
156-
public ContentBuilder extension(ExtensionBuilder extensionBuilder) {
156+
public Builder extension(org.springdoc.core.fn.builders.extension.Builder extensionBuilder) {
157157
this.extensions = ArrayUtils.add( this.extensions, extensionBuilder.build());
158158
return this;
159159
}

0 commit comments

Comments
 (0)