Skip to content

Commit

Permalink
syntax improvment. Fixes #891
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Oct 28, 2020
1 parent e0da230 commit f4e2ac4
Show file tree
Hide file tree
Showing 36 changed files with 181 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public abstract class AbstractSpringdocRouteBuilder {

protected Builder getOperationBuilder(Consumer<Builder> operationsConsumer) {
Builder builder = Builder.operation();
Builder builder = Builder.operationBuilder();
operationsConsumer.accept(builder);
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private Builder() {
*
* @return the api response builder
*/
public static Builder apiResponse() {
public static Builder apiResponseBuilder() {
return new Builder();
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public Builder content(org.springdoc.core.fn.builders.content.Builder contentBui
* @return the api response builder
*/
public Builder implementation(Class clazz) {
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());
this.content = ArrayUtils.add(this.content, org.springdoc.core.fn.builders.content.Builder.contentBuilder().schema(org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().implementation(clazz)).build());
return this;
}

Expand All @@ -170,7 +170,7 @@ public Builder implementation(Class clazz) {
* @return the api response builder
*/
public Builder implementationArray(Class clazz) {
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());
this.content = ArrayUtils.add(this.content, org.springdoc.core.fn.builders.content.Builder.contentBuilder().array(org.springdoc.core.fn.builders.arrayschema.Builder.arraySchemaBuilder().schema(org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().implementation(clazz))).build());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class Builder {
* The schema of the items in the array
*
*/
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().build();

/**
* Allows to define the properties to be resolved into properties of the schema of type `array` (not the ones of the
* `items` of such schema which are defined in schema}.
*
*/
private Schema arraySchema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
private Schema arraySchema = org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().build();

/**
* sets the maximum number of items in an array. Ignored if value is Integer.MIN_VALUE.
Expand Down Expand Up @@ -84,7 +84,7 @@ private Builder() {
*
* @return the array schema builder
*/
public static Builder arraySchema() {
public static Builder arraySchemaBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public class Builder {
* The schema defining the type used for the content.
*
*/
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().build();

/**
* The schema of the array that defines the type used for the content.
*
*/
private ArraySchema array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchema().build();
private ArraySchema array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchemaBuilder().build();

/**
* An array of encodings
Expand All @@ -88,7 +88,7 @@ private Builder() {
*
* @return the content builder
*/
public static Builder content() {
public static Builder contentBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private Builder() {
*
* @return the discriminator mapping builder
*/
public static Builder discriminatorMapping() {
public static Builder discriminatorMappingBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private Builder() {
*
* @return the encoding builder
*/
public static Builder encoding() {
public static Builder encodingBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private Builder() {
*
* @return the example object builder
*/
public static Builder exampleOject() {
public static Builder exampleOjectBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private Builder() {
*
* @return the extension builder
*/
public static Builder extension() {
public static Builder extensionBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private Builder() {
*
* @return the extension property builder
*/
public static Builder extensionProperty() {
public static Builder extensionPropertyBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private Builder() {
*
* @return the external documentation builder
*/
public static Builder externalDocumentation() {
public static Builder externalDocumentationBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class Builder {
* The schema defining the type used for the header. Ignored if the properties content or array are specified.
*
*/
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().build();

/**
* Determines whether this header is mandatory. The property may be included and its default value is false.
Expand Down Expand Up @@ -81,7 +81,7 @@ private Builder() {
*
* @return the header builder
*/
public static Builder header() {
public static Builder headerBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class Builder {
* An alternative server to service this operation.
*
*/
private Server server = org.springdoc.core.fn.builders.server.Builder.server().build();
private Server server = org.springdoc.core.fn.builders.server.Builder.serverBuilder().build();

/**
* The list of optional extensions
Expand All @@ -103,7 +103,7 @@ private Builder() {
*
* @return the link builder
*/
public static Builder builder() {
public static Builder linkBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private Builder() {
*
* @return the link parameter builder
*/
public static Builder linkParameter() {
public static Builder linkParameterBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public class Builder {
* Request body associated to the operation.
*
*/
private RequestBody requestBody = org.springdoc.core.fn.builders.requestbody.Builder.requestBody().build();
private RequestBody requestBody = org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder().build();

/**
* Additional external documentation for this operation.
*
*/
private ExternalDocumentation externalDocs = org.springdoc.core.fn.builders.externaldocumentation.Builder.externalDocumentation().build();
private ExternalDocumentation externalDocs = org.springdoc.core.fn.builders.externaldocumentation.Builder.externalDocumentationBuilder().build();

/**
* The operationId is used by third-party tools to uniquely identify this operation.
Expand Down Expand Up @@ -160,7 +160,7 @@ private Builder() {
*
* @return the operation builder
*/
public static Builder operation() {
public static Builder operationBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ public class Builder {
* The schema defining the type used for the parameter. Ignored if the properties content or array are specified.
*
*/
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schema().build();
private Schema schema = org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().build();

/**
* The schema of the array that defines this parameter. Ignored if the property content is specified.
*
*/
private ArraySchema array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchema().build();
private ArraySchema array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchemaBuilder().build();

/**
* The representation of this parameter, for different media types.
Expand Down Expand Up @@ -156,7 +156,7 @@ private Builder() {
*
* @return the parameter builder
*/
public static Builder parameter() {
public static Builder parameterBuilder() {
return new Builder();
}

Expand Down Expand Up @@ -288,7 +288,7 @@ public Builder array(org.springdoc.core.fn.builders.arrayschema.Builder arraySch
* @return the parameter builder
*/
public Builder implementationArray(Class clazz) {
this.array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchema().schema(org.springdoc.core.fn.builders.schema.Builder.schema().implementation(clazz)).build();
this.array = org.springdoc.core.fn.builders.arrayschema.Builder.arraySchemaBuilder().schema(org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().implementation(clazz)).build();
return this;
}

Expand All @@ -299,7 +299,7 @@ public Builder implementationArray(Class clazz) {
* @return the parameter builder
*/
public Builder implementation(Class clazz) {
this.schema = org.springdoc.core.fn.builders.schema.Builder.schema().implementation(clazz).build();
this.schema = org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().implementation(clazz).build();
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private Builder() {
*
* @return the request body builder
*/
public static Builder requestBody() {
public static Builder requestBodyBuilder() {
return new Builder();
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public Builder content(org.springdoc.core.fn.builders.content.Builder contentBui
* @return the request body builder
*/
public Builder implementation(Class clazz) {
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());
this.content = ArrayUtils.add(this.content, org.springdoc.core.fn.builders.content.Builder.contentBuilder().schema(org.springdoc.core.fn.builders.schema.Builder.schemaBuilder().implementation(clazz)).build());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public class Builder {
* Additional external documentation for this schema.
*
*/
private ExternalDocumentation externalDocs = org.springdoc.core.fn.builders.externaldocumentation.Builder.externalDocumentation().build();
private ExternalDocumentation externalDocs = org.springdoc.core.fn.builders.externaldocumentation.Builder.externalDocumentationBuilder().build();

/**
* Specifies that a schema is deprecated and should be transitioned out of usage.
Expand Down Expand Up @@ -272,7 +272,7 @@ private Builder() {
*
* @return the schema builder
*/
public static Builder schema() {
public static Builder schemaBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private Builder() {
*
* @return the security requirement builder
*/
public static Builder securityRequirement() {
public static Builder securityRequirementBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private Builder() {
*
* @return the server builder
*/
public static Builder server() {
public static Builder serverBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private Builder() {
*
* @return the server variable builder
*/
public static Builder serverVariable() {
public static Builder serverVariableBuilder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springdoc.core.Constants.OPERATION_ATTRIBUTE;
import static org.springdoc.core.fn.builders.operation.Builder.operation;
import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
Expand All @@ -21,19 +21,19 @@ public class RoutingConfiguration {
@Bean
public RouterFunction<ServerResponse> monoRouterFunction(UserHandler userHandler) {
return route(GET("/api/user/index").and(accept(APPLICATION_JSON)), userHandler::getAll)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(UserRepository.class).beanMethod("getAllUsers"))
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getAllUsers"))

.and(route(GET("/api/user/{id}").and(accept(APPLICATION_JSON)), userHandler::getUser)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(UserRepository.class).beanMethod("getUserById")))
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getUserById")))

.and(route(POST("/api/user/post").and(accept(APPLICATION_JSON)), userHandler::postUser)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(UserRepository.class).beanMethod("saveUser")))
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("saveUser")))

.and(route(PUT("/api/user/put/{id}").and(accept(APPLICATION_JSON)), userHandler::putUser)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(UserRepository.class).beanMethod("putUser")))
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("putUser")))

.and(route(DELETE("/api/user/delete/{id}").and(accept(APPLICATION_JSON)), userHandler::deleteUser)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(UserRepository.class).beanMethod("deleteUser")));
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("deleteUser")));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springdoc.core.Constants.OPERATION_ATTRIBUTE;
import static org.springdoc.core.fn.builders.operation.Builder.operation;
import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

Expand All @@ -25,13 +25,13 @@ public RouteConfig(CoffeeService service) {
@Bean
RouterFunction<ServerResponse> routerFunction() {
return route(GET("/coffees"), this::all)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(CoffeeService.class).beanMethod("getAllCoffees"))
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getAllCoffees"))

.and(route(GET("/coffees/{id}"), this::byId)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(CoffeeService.class).beanMethod("getCoffeeById")))
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getCoffeeById")))

.and(route(GET("/coffees/{id}/orders"), this::orders)
.withAttribute(OPERATION_ATTRIBUTE, operation().beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById")));
.withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById")));
}

private Mono<ServerResponse> all(ServerRequest req) {
Expand Down
Loading

0 comments on commit f4e2ac4

Please sign in to comment.