Skip to content

Commit

Permalink
Default implementation for builder methods
Browse files Browse the repository at this point in the history
Issue #236
Signed-off-by: Jeremie Bresson <dev@jmini.fr>
  • Loading branch information
jmini committed Jul 23, 2018
1 parent 7449876 commit 011e357
Show file tree
Hide file tree
Showing 27 changed files with 686 additions and 171 deletions.
Expand Up @@ -71,7 +71,10 @@ public interface Components extends Constructible, Extensible {
* @param schemas a Map containing keys and reusable schemas
* @return the current Components object
*/
Components schemas(Map<String, Schema> schemas);
default Components schemas(Map<String, Schema> schemas) {
setSchemas(schemas);
return this;
}

/**
* Adds the given schema to this Components' list of schemas with the given string as its key.
Expand Down Expand Up @@ -102,7 +105,10 @@ public interface Components extends Constructible, Extensible {
* @param responses a Map containing keys and reusable response objects
* @return the current Components object
*/
Components responses(Map<String, APIResponse> responses);
default Components responses(Map<String, APIResponse> responses) {
setResponses(responses);
return this;
}

/**
* Adds the given response to this Components' map of responses with the given string as its key.
Expand Down Expand Up @@ -133,7 +139,10 @@ public interface Components extends Constructible, Extensible {
* @param parameters a Map containing keys and reusable parameter objects
* @return the current Components object
*/
Components parameters(Map<String, Parameter> parameters);
default Components parameters(Map<String, Parameter> parameters) {
setParameters(parameters);
return this;
}

/**
* Adds the given parameter to this Components' map of parameters with the given string as its key.
Expand Down Expand Up @@ -164,7 +173,10 @@ public interface Components extends Constructible, Extensible {
* @param examples a Map containing keys and reusable example objects
* @return the current Components object
*/
Components examples(Map<String, Example> examples);
default Components examples(Map<String, Example> examples) {
setExamples(examples);
return this;
}

/**
* Adds the given example to this Components' map of examples with the given string as its key.
Expand Down Expand Up @@ -195,7 +207,10 @@ public interface Components extends Constructible, Extensible {
* @param requestBodies a Map containing the keys and reusable request body objects
* @return the current Components object
*/
Components requestBodies(Map<String, RequestBody> requestBodies);
default Components requestBodies(Map<String, RequestBody> requestBodies) {
setRequestBodies(requestBodies);
return this;
}

/**
* Adds the given request body to this Components' map of request bodies with the given string as its key.
Expand Down Expand Up @@ -226,7 +241,10 @@ public interface Components extends Constructible, Extensible {
* @param headers a Map containing the keys and reusable header objects
* @return the current Components object
*/
Components headers(Map<String, Header> headers);
default Components headers(Map<String, Header> headers) {
setHeaders(headers);
return this;
}

/**
* Adds the given header to this Components' map of headers with the given string as its key.
Expand Down Expand Up @@ -257,7 +275,10 @@ public interface Components extends Constructible, Extensible {
* @param securitySchemes a Map containing the keys and reusable security scheme objects
* @return the current Components object
*/
Components securitySchemes(Map<String, SecurityScheme> securitySchemes);
default Components securitySchemes(Map<String, SecurityScheme> securitySchemes) {
setSecuritySchemes(securitySchemes);
return this;
}

/**
* Adds the given security scheme to this Components' map of security schemes with the given string as its key.
Expand Down Expand Up @@ -288,7 +309,10 @@ public interface Components extends Constructible, Extensible {
* @param links a Map containing the keys and reusable link objects
* @return the current Components object
*/
Components links(Map<String, Link> links);
default Components links(Map<String, Link> links) {
setLinks(links);
return this;
}

/**
* Adds the given link to this Components' map of links with the given string as its key.
Expand Down Expand Up @@ -319,7 +343,10 @@ public interface Components extends Constructible, Extensible {
* @param callbacks a Map containing the keys and reusable callback objects
* @return the current Components object
*/
Components callbacks(Map<String, Callback> callbacks);
default Components callbacks(Map<String, Callback> callbacks) {
setCallbacks(callbacks);
return this;
}

/**
* Adds the given callback to this Components' map of callbacks with the given string as its key.
Expand Down
Expand Up @@ -48,7 +48,10 @@ public interface ExternalDocumentation extends Constructible, Extensible {
* @param description a short description of the target documentation
* @return the current ExternalDocumentation instance
*/
ExternalDocumentation description(String description);
default ExternalDocumentation description(String description) {
setDescription(description);
return this;
}

/**
* Returns the url property from an ExternalDocumentation instance.
Expand All @@ -70,6 +73,9 @@ public interface ExternalDocumentation extends Constructible, Extensible {
* @param url the URL for the target documentation
* @return the current ExternalDocumentation instance
*/
ExternalDocumentation url(String url);
default ExternalDocumentation url(String url) {
setUrl(url);
return this;
}

}
Expand Up @@ -53,7 +53,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param openapi the semantic version number of the OpenAPI Specification version that the OpenAPI document uses
* @return the current OpenAPI object
*/
OpenAPI openapi(String openapi);
default OpenAPI openapi(String openapi) {
setOpenapi(openapi);
return this;
}

/**
* Returns the info property from an OpenAPI instance.
Expand All @@ -75,7 +78,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param info metadata about the API
* @return the current OpenAPI object
*/
OpenAPI info(Info info);
default OpenAPI info(Info info) {
setInfo(info);
return this;
}

/**
* Returns the externalDocs property from an OpenAPI instance.
Expand All @@ -97,7 +103,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param externalDocs additional external documentation
* @return the current OpenAPI object
*/
OpenAPI externalDocs(ExternalDocumentation externalDocs);
default OpenAPI externalDocs(ExternalDocumentation externalDocs) {
setExternalDocs(externalDocs);
return this;
}

/**
* Returns the Servers defined in the API
Expand All @@ -119,7 +128,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param servers Server objects which provide connectivity information to target servers
* @return the current OpenAPI object
*/
OpenAPI servers(List<Server> servers);
default OpenAPI servers(List<Server> servers) {
setServers(servers);
return this;
}

/**
* Adds the given server to this OpenAPI instance's list of servers.
Expand Down Expand Up @@ -149,7 +161,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param security which security mechanisms can be used across the API
* @return the current OpenAPI object
*/
OpenAPI security(List<SecurityRequirement> security);
default OpenAPI security(List<SecurityRequirement> security) {
setSecurity(security);
return this;
}

/**
* Adds the given security requirement to this OpenAPI instance's list of security requirements.
Expand Down Expand Up @@ -180,7 +195,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param tags tags used by the specification with additional metadata
* @return the current OpenAPI object
*/
OpenAPI tags(List<Tag> tags);
default OpenAPI tags(List<Tag> tags) {
setTags(tags);
return this;
}

/**
* Adds the given tag to this OpenAPI instance's list of tags.
Expand Down Expand Up @@ -210,7 +228,10 @@ public interface OpenAPI extends Constructible, Extensible {
* @param paths the available paths and operations for the API
* @return the current OpenAPI object
*/
OpenAPI paths(Paths paths);
default OpenAPI paths(Paths paths) {
setPaths(paths);
return this;
}

/**
* Adds the given path item to this OpenAPI instance's list of paths
Expand Down Expand Up @@ -241,6 +262,9 @@ public interface OpenAPI extends Constructible, Extensible {
* @param components a set of reusable objects used in the API specification
* @return the current OpenAPI object
*/
OpenAPI components(Components components);
default OpenAPI components(Components components) {
setComponents(components);
return this;
}

}
Expand Up @@ -58,7 +58,10 @@ public interface Operation extends Constructible, Extensible {
* @param tags a list of tags for API documentation control
* @return the current Operation object
**/
Operation tags(List<String> tags);
default Operation tags(List<String> tags) {
setTags(tags);
return this;
}

/**
* Adds the given tag to this Operation's list of tags.
Expand Down Expand Up @@ -88,7 +91,10 @@ public interface Operation extends Constructible, Extensible {
* @param summary a short summary of what the operation does
* @return the current Operation object
**/
Operation summary(String summary);
default Operation summary(String summary) {
setSummary(summary);
return this;
}

/**
* Returns the description property from an Operation instance.
Expand All @@ -110,7 +116,10 @@ public interface Operation extends Constructible, Extensible {
* @param description a verbose explanation of the operation behavior
* @return the current Operation object
**/
Operation description(String description);
default Operation description(String description) {
setDescription(description);
return this;
}

/**
* Returns the externalDocs property from an Operation instance.
Expand All @@ -132,7 +141,10 @@ public interface Operation extends Constructible, Extensible {
* @param externalDocs additional external documentation for this operation
* @return the current Operation object
**/
Operation externalDocs(ExternalDocumentation externalDocs);
default Operation externalDocs(ExternalDocumentation externalDocs) {
setExternalDocs(externalDocs);
return this;
}

/**
* Returns the operationId property from an Operation instance.
Expand All @@ -154,7 +166,10 @@ public interface Operation extends Constructible, Extensible {
* @param operationId unique string used to identify the operation
* @return the current Operation object
**/
Operation operationId(String operationId);
default Operation operationId(String operationId) {
setOperationId(operationId);
return this;
}

/**
* Returns the parameters property from an Operation instance.
Expand All @@ -176,7 +191,10 @@ public interface Operation extends Constructible, Extensible {
* @param parameters a list of parameters that are applicable for this operation
* @return the current Operation object
**/
Operation parameters(List<Parameter> parameters);
default Operation parameters(List<Parameter> parameters) {
setParameters(parameters);
return this;
}

/**
* Adds the given parameter item to this Operation's list of parameters.
Expand Down Expand Up @@ -206,7 +224,10 @@ public interface Operation extends Constructible, Extensible {
* @param requestBody the request body applicable for this operation
* @return the current Operation object
**/
Operation requestBody(RequestBody requestBody);
default Operation requestBody(RequestBody requestBody) {
setRequestBody(requestBody);
return this;
}

/**
* Returns the responses property from an Operation instance.
Expand All @@ -228,7 +249,10 @@ public interface Operation extends Constructible, Extensible {
* @param responses collection of possible responses from executing this operation
* @return the current Operation object
**/
Operation responses(APIResponses responses);
default Operation responses(APIResponses responses) {
setResponses(responses);
return this;
}

/**
* Returns the callbacks property from an Operation instance.
Expand All @@ -250,7 +274,10 @@ public interface Operation extends Constructible, Extensible {
* @param callbacks map of possible out-of-band callbacks related to the operation. The key value must be the correct format for this field.
* @return the current Operation object
**/
Operation callbacks(Map<String, Callback> callbacks);
default Operation callbacks(Map<String, Callback> callbacks) {
setCallbacks(callbacks);
return this;
}

/**
* Returns the deprecated property from an Operation instance.
Expand All @@ -272,7 +299,10 @@ public interface Operation extends Constructible, Extensible {
* @param deprecated declaration whether this operation is deprecated
* @return the current Operation object
**/
Operation deprecated(Boolean deprecated);
default Operation deprecated(Boolean deprecated) {
setDeprecated(deprecated);
return this;
}

/**
* Returns the security property from an Operation instance.
Expand All @@ -294,7 +324,10 @@ public interface Operation extends Constructible, Extensible {
* @param security list of which security mechanisms can be used for this operation
* @return the current Operation object
**/
Operation security(List<SecurityRequirement> security);
default Operation security(List<SecurityRequirement> security) {
setSecurity(security);
return this;
}

/**
* Adds the given security requirement item to this Operation's list of security mechanisms.
Expand Down Expand Up @@ -324,7 +357,10 @@ public interface Operation extends Constructible, Extensible {
* @param servers list of servers to service this operation
* @return the current Operation object
**/
Operation servers(List<Server> servers);
default Operation servers(List<Server> servers) {
setServers(servers);
return this;
}

/**
* Adds the given server to this Operation's list of servers.
Expand Down

0 comments on commit 011e357

Please sign in to comment.