From 011e35713309f27addfc3ae2cda9e22b32f80c66 Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Thu, 19 Jul 2018 16:38:34 +0200 Subject: [PATCH] Default implementation for builder methods Issue #236 Signed-off-by: Jeremie Bresson --- .../openapi/models/Components.java | 45 ++++- .../openapi/models/ExternalDocumentation.java | 10 +- .../microprofile/openapi/models/OpenAPI.java | 40 ++++- .../openapi/models/Operation.java | 60 +++++-- .../microprofile/openapi/models/PathItem.java | 60 +++++-- .../openapi/models/Reference.java | 7 +- .../openapi/models/examples/Example.java | 20 ++- .../openapi/models/headers/Header.java | 50 ++++-- .../openapi/models/info/Contact.java | 15 +- .../openapi/models/info/Info.java | 30 +++- .../openapi/models/info/License.java | 10 +- .../openapi/models/links/Link.java | 30 +++- .../openapi/models/media/Discriminator.java | 10 +- .../openapi/models/media/Encoding.java | 25 ++- .../openapi/models/media/MediaType.java | 20 ++- .../openapi/models/media/Schema.java | 170 ++++++++++++++---- .../openapi/models/media/XML.java | 25 ++- .../openapi/models/parameters/Parameter.java | 65 +++++-- .../models/parameters/RequestBody.java | 15 +- .../openapi/models/responses/APIResponse.java | 20 ++- .../models/responses/APIResponses.java | 5 +- .../openapi/models/security/OAuthFlow.java | 20 ++- .../openapi/models/security/OAuthFlows.java | 20 ++- .../models/security/SecurityScheme.java | 40 ++++- .../openapi/models/servers/Server.java | 15 +- .../models/servers/ServerVariable.java | 15 +- .../microprofile/openapi/models/tags/Tag.java | 15 +- 27 files changed, 686 insertions(+), 171 deletions(-) diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/Components.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/Components.java index 6a784dd60..3c59bd1bf 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/Components.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/Components.java @@ -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 schemas); + default Components schemas(Map schemas) { + setSchemas(schemas); + return this; + } /** * Adds the given schema to this Components' list of schemas with the given string as its key. @@ -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 responses); + default Components responses(Map responses) { + setResponses(responses); + return this; + } /** * Adds the given response to this Components' map of responses with the given string as its key. @@ -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 parameters); + default Components parameters(Map parameters) { + setParameters(parameters); + return this; + } /** * Adds the given parameter to this Components' map of parameters with the given string as its key. @@ -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 examples); + default Components examples(Map examples) { + setExamples(examples); + return this; + } /** * Adds the given example to this Components' map of examples with the given string as its key. @@ -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 requestBodies); + default Components requestBodies(Map requestBodies) { + setRequestBodies(requestBodies); + return this; + } /** * Adds the given request body to this Components' map of request bodies with the given string as its key. @@ -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 headers); + default Components headers(Map headers) { + setHeaders(headers); + return this; + } /** * Adds the given header to this Components' map of headers with the given string as its key. @@ -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 securitySchemes); + default Components securitySchemes(Map securitySchemes) { + setSecuritySchemes(securitySchemes); + return this; + } /** * Adds the given security scheme to this Components' map of security schemes with the given string as its key. @@ -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 links); + default Components links(Map links) { + setLinks(links); + return this; + } /** * Adds the given link to this Components' map of links with the given string as its key. @@ -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 callbacks); + default Components callbacks(Map callbacks) { + setCallbacks(callbacks); + return this; + } /** * Adds the given callback to this Components' map of callbacks with the given string as its key. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/ExternalDocumentation.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/ExternalDocumentation.java index 13a817fdb..baba074ec 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/ExternalDocumentation.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/ExternalDocumentation.java @@ -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. @@ -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; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/OpenAPI.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/OpenAPI.java index eb2928b99..e2b9e50c9 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/OpenAPI.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/OpenAPI.java @@ -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. @@ -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. @@ -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 @@ -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 servers); + default OpenAPI servers(List servers) { + setServers(servers); + return this; + } /** * Adds the given server to this OpenAPI instance's list of servers. @@ -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 security); + default OpenAPI security(List security) { + setSecurity(security); + return this; + } /** * Adds the given security requirement to this OpenAPI instance's list of security requirements. @@ -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 tags); + default OpenAPI tags(List tags) { + setTags(tags); + return this; + } /** * Adds the given tag to this OpenAPI instance's list of tags. @@ -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 @@ -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; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java index 33b84339d..13a84c53c 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/Operation.java @@ -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 tags); + default Operation tags(List tags) { + setTags(tags); + return this; + } /** * Adds the given tag to this Operation's list of tags. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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 parameters); + default Operation parameters(List parameters) { + setParameters(parameters); + return this; + } /** * Adds the given parameter item to this Operation's list of parameters. @@ -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. @@ -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. @@ -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 callbacks); + default Operation callbacks(Map callbacks) { + setCallbacks(callbacks); + return this; + } /** * Returns the deprecated property from an Operation instance. @@ -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. @@ -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 security); + default Operation security(List security) { + setSecurity(security); + return this; + } /** * Adds the given security requirement item to this Operation's list of security mechanisms. @@ -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 servers); + default Operation servers(List servers) { + setServers(servers); + return this; + } /** * Adds the given server to this Operation's list of servers. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/PathItem.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/PathItem.java index f8a80f0ad..d02796821 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/PathItem.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/PathItem.java @@ -64,7 +64,10 @@ enum HttpMethod { * @param summary short summary of what the path item represents * @return the current PathItem instance **/ - PathItem summary(String summary); + default PathItem summary(String summary) { + setSummary(summary); + return this; + } /** * Returns the description property from a PathItem instance. @@ -86,7 +89,10 @@ enum HttpMethod { * @param description detailed description of what the path item represents * @return the current PathItem instance **/ - PathItem description(String description); + default PathItem description(String description) { + setDescription(description); + return this; + } /** * Returns the get property from a PathItem instance. @@ -108,7 +114,10 @@ enum HttpMethod { * @param get definition of a GET operation * @return the current PathItem instance **/ - PathItem GET(Operation get); + default PathItem GET(Operation get) { + setGET(get); + return this; + } /** * Returns the put property from a PathItem instance. @@ -130,7 +139,10 @@ enum HttpMethod { * @param put definition of a PUT operation * @return the current PathItem instance **/ - PathItem PUT(Operation put); + default PathItem PUT(Operation put) { + setPUT(put); + return this; + } /** * Returns the post property from a PathItem instance. @@ -152,7 +164,10 @@ enum HttpMethod { * @param post definition of a PUT operation * @return the current PathItem instance **/ - PathItem POST(Operation post); + default PathItem POST(Operation post) { + setPOST(post); + return this; + } /** * Returns the delete property from a PathItem instance. @@ -174,7 +189,10 @@ enum HttpMethod { * @param delete definition of a DELETE operation * @return the current PathItem instance **/ - PathItem DELETE(Operation delete); + default PathItem DELETE(Operation delete) { + setDELETE(delete); + return this; + } /** * Returns the options property from a PathItem instance. @@ -196,7 +214,10 @@ enum HttpMethod { * @param options definition of an OPTIONS operation * @return the current PathItem instance **/ - PathItem OPTIONS(Operation options); + default PathItem OPTIONS(Operation options) { + setOPTIONS(options); + return this; + } /** * Returns the head property from a PathItem instance. @@ -218,7 +239,10 @@ enum HttpMethod { * @param head definition of a HEAD operation * @return the current PathItem instance **/ - PathItem HEAD(Operation head); + default PathItem HEAD(Operation head) { + setHEAD(head); + return this; + } /** * Returns the patch property from a PathItem instance. @@ -240,7 +264,10 @@ enum HttpMethod { * @param patch definition of a PATCH operation * @return the current PathItem instance **/ - PathItem PATCH(Operation patch); + default PathItem PATCH(Operation patch) { + setPATCH(patch); + return this; + } /** * Returns the trace property from a PathItem instance. @@ -262,7 +289,10 @@ enum HttpMethod { * @param trace definition of a TRACE operation * @return the current PathItem instance **/ - PathItem TRACE(Operation trace); + default PathItem TRACE(Operation trace) { + setTRACE(trace); + return this; + } /** * Returns a list of all the operations for this path item. @@ -313,7 +343,10 @@ default Map readOperationsMap() { * @param servers a list of the servers to service operations in this path item * @return the current PathItem instance **/ - PathItem servers(List servers); + default PathItem servers(List servers) { + setServers(servers); + return this; + } /** * Adds the given server to this PathItem's list of servers. @@ -343,7 +376,10 @@ default Map readOperationsMap() { * @param parameters a list of parameters that are applicable to all the operations described under this path * @return the current PathItem instance **/ - PathItem parameters(List parameters); + default PathItem parameters(List parameters) { + setParameters(parameters); + return this; + } /** * Adds the given parameter to this PathItem's list of parameters. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/Reference.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/Reference.java index 420db34c0..23511d5cc 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/Reference.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/Reference.java @@ -64,6 +64,11 @@ public interface Reference> { * @param ref a reference to a T object in the components in this OpenAPI document * @return the current instance **/ - T ref(String ref); + default T ref(String ref) { + setRef(ref); + @SuppressWarnings("unchecked") + T t = (T) this; + return t; + } } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/examples/Example.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/examples/Example.java index c927abc5c..aa10faa3e 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/examples/Example.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/examples/Example.java @@ -53,7 +53,10 @@ public interface Example extends Constructible, Extensible, Reference { * @param summary short description of the example * @return the current Example object */ - Example summary(String summary); + default Example summary(String summary) { + setSummary(summary); + return this; + } /** * Returns the description property from an Example instance. @@ -75,7 +78,10 @@ public interface Example extends Constructible, Extensible, Reference { * @param description long description of the example * @return the current Example object */ - Example description(String description); + default Example description(String description) { + setDescription(description); + return this; + } /** * Returns the value property from an Example instance. @@ -97,7 +103,10 @@ public interface Example extends Constructible, Extensible, Reference { * @param value a literal example object * @return the current Example object */ - Example value(Object value); + default Example value(Object value) { + setValue(value); + return this; + } /** * Returns the externalValue property from an Example instance. @@ -119,6 +128,9 @@ public interface Example extends Constructible, Extensible, Reference { * @param externalValue URL that points to the literal example * @return the current Example object */ - Example externalValue(String externalValue); + default Example externalValue(String externalValue) { + setExternalValue(externalValue); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/headers/Header.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/headers/Header.java index 06a0b91bb..a4d32617e 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/headers/Header.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/headers/Header.java @@ -74,7 +74,10 @@ public String toString() { * @param description a brief description of the header parameter * @return the current Header instance */ - Header description(String description); + default Header description(String description) { + setDescription(description); + return this; + } /** * Returns the required property from a Header instance. @@ -96,7 +99,10 @@ public String toString() { * @param required whether this parameter is mandatory * @return the current Header instance */ - Header required(Boolean required); + default Header required(Boolean required) { + setRequired(required); + return this; + } /** * Returns the deprecated property from a Header instance. @@ -118,7 +124,10 @@ public String toString() { * @param deprecated whether the header parameter is deprecated * @return the current Header instance */ - Header deprecated(Boolean deprecated); + default Header deprecated(Boolean deprecated) { + setDeprecated(deprecated); + return this; + } /** * Returns the allowEmptyValue property from a Header instance. @@ -140,7 +149,10 @@ public String toString() { * @param allowEmptyValue specify the ability to pass empty-valued parameters * @return the current Header instance */ - Header allowEmptyValue(Boolean allowEmptyValue); + default Header allowEmptyValue(Boolean allowEmptyValue) { + setAllowEmptyValue(allowEmptyValue); + return this; + } /** * Returns the style property from a Header instance. @@ -162,7 +174,10 @@ public String toString() { * @param style how the parameter value will be serialized * @return the current Header instance */ - Header style(Style style); + default Header style(Style style) { + setStyle(style); + return this; + } /** * Returns the explode property from a Header instance. @@ -184,7 +199,10 @@ public String toString() { * @param explode whether parameter values of type "array" or "object" generate separate parameters for each value * @return the current Header instance */ - Header explode(Boolean explode); + default Header explode(Boolean explode) { + setExplode(explode); + return this; + } /** * Returns the schema property from a Header instance. @@ -206,7 +224,10 @@ public String toString() { * @param schema schema defining the type used for the header parameter * @return the current Header instance */ - Header schema(Schema schema); + default Header schema(Schema schema) { + setSchema(schema); + return this; + } /** * Returns the examples property from a Header instance. @@ -230,7 +251,10 @@ public String toString() { * @param examples examples of the media type * @return the current Header instance */ - Header examples(Map examples); + default Header examples(Map examples) { + setExamples(examples); + return this; + } /** * Adds an example of the media type using the specified key to this Header instance. The example should contain a value in the correct format as @@ -264,7 +288,10 @@ public String toString() { * @param example example of the media type * @return the current Header instance */ - Header example(Object example); + default Header example(Object example) { + setExample(example); + return this; + } /** * Returns the content property from a Header instance. @@ -286,6 +313,9 @@ public String toString() { * @param content a map containing the media representations for the parameter * @return the current Header instance */ - Header content(Content content); + default Header content(Content content) { + setContent(content); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Contact.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Contact.java index 84785b917..c43d6a007 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Contact.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Contact.java @@ -47,7 +47,10 @@ public interface Contact extends Constructible, Extensible { * @param name the name of the contact person/organization * @return this Contact instance */ - Contact name(String name); + default Contact name(String name) { + setName(name); + return this; + } /** * Returns the URL pointing to the contact information for this Contact instance. @@ -71,7 +74,10 @@ public interface Contact extends Constructible, Extensible { * @param url the url pointing to the contact information * @return this Contact instance */ - Contact url(String url); + default Contact url(String url) { + setUrl(url); + return this; + } /** * Returns the contact email of this Contact instance. @@ -94,6 +100,9 @@ public interface Contact extends Constructible, Extensible { * @param email the email of the contact person/organization * @return this Contact instance */ - Contact email(String email); + default Contact email(String email) { + setEmail(email); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Info.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Info.java index 108876c2b..f6d54b9b2 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/info/Info.java @@ -49,7 +49,10 @@ public interface Info extends Constructible, Extensible { * @param title the title of the application * @return this Info instance */ - Info title(String title); + default Info title(String title) { + setTitle(title); + return this; + } /** * Returns a short description for the application for this Info instance. @@ -72,7 +75,10 @@ public interface Info extends Constructible, Extensible { * @param description a short description for the application * @return this Info instance */ - Info description(String description); + default Info description(String description) { + setDescription(description); + return this; + } /** * Returns the URL to the Terms of Service for the API for this instance of Info. @@ -96,7 +102,10 @@ public interface Info extends Constructible, Extensible { * @param termsOfService the URL to the Terms of Service for the API * @return this Info instance */ - Info termsOfService(String termsOfService); + default Info termsOfService(String termsOfService) { + setTermsOfService(termsOfService); + return this; + } /** * Returns the contact information for the exposed API from this Info instance. @@ -119,7 +128,10 @@ public interface Info extends Constructible, Extensible { * @param contact the contact information for the exposed API * @return this Info instance */ - Info contact(Contact contact); + default Info contact(Contact contact) { + setContact(contact); + return this; + } /** * Returns the license information for the exposed API from this Info instance. @@ -142,7 +154,10 @@ public interface Info extends Constructible, Extensible { * @param license the license information for the exposed API * @return this Info instance */ - Info license(License license); + default Info license(License license) { + setLicense(license); + return this; + } /** * Returns the version of the OpenAPI document for this Info instance. @@ -165,6 +180,9 @@ public interface Info extends Constructible, Extensible { * @param version the version of the OpenAPI document * @return this Info instance */ - Info version(String version); + default Info version(String version) { + setVersion(version); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/info/License.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/info/License.java index cf383f0b6..4e6aa0e9b 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/info/License.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/info/License.java @@ -47,7 +47,10 @@ public interface License extends Constructible, Extensible { * @param name the license name used for the API * @return this License instance */ - License name(String name); + default License name(String name) { + setName(name); + return this; + } /** * Returns the URL for this License instance that is used for the API. @@ -70,6 +73,9 @@ public interface License extends Constructible, Extensible { * @param url the URL to the license used for the API * @return this License instance */ - License url(String url); + default License url(String url) { + setUrl(url); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/links/Link.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/links/Link.java index 859772c59..a8654070d 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/links/Link.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/links/Link.java @@ -62,7 +62,10 @@ public interface Link extends Constructible, Extensible, Reference { * @param server a server object to be used by the target operation * @return the current Link instance */ - Link server(Server server); + default Link server(Server server) { + setServer(server); + return this; + } /** * Returns the operationRef property from a Link instance. @@ -84,7 +87,10 @@ public interface Link extends Constructible, Extensible, Reference { * @param operationRef a relative or absolute reference to an OAS operation * @return the current Link instance */ - Link operationRef(String operationRef); + default Link operationRef(String operationRef) { + setOperationRef(operationRef); + return this; + } /** * Returns the requestBody property from a Link instance. @@ -106,7 +112,10 @@ public interface Link extends Constructible, Extensible, Reference { * @param requestBody a literal value or runtime expression to use as a request body when calling the target operation * @return the current Link instance */ - Link requestBody(Object requestBody); + default Link requestBody(Object requestBody) { + setRequestBody(requestBody); + return this; + } /** * Returns the operationId property for this instance of Link. @@ -128,7 +137,10 @@ public interface Link extends Constructible, Extensible, Reference { * @param operationId the name of an existing, resolvable OAS operation * @return the current Link instance */ - Link operationId(String operationId); + default Link operationId(String operationId) { + setOperationId(operationId); + return this; + } /** * Returns the parameters property from this instance of Link. The key is the parameter name and the value is a constant or a runtime expression @@ -151,7 +163,10 @@ public interface Link extends Constructible, Extensible, Reference { * @param parameters a map representing parameters to pass to this link's operation as specified with operationId or identified via operationRef * @return current link instance */ - Link parameters(Map parameters); + default Link parameters(Map parameters) { + setParameters(parameters); + return this; + } /** * Add a new parameter to the parameters property of this instance of Link. @@ -183,6 +198,9 @@ public interface Link extends Constructible, Extensible, Reference { * @param description a description of the link * @return the current Link instance */ - Link description(String description); + default Link description(String description) { + setDescription(description); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Discriminator.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Discriminator.java index 5d9f8ceff..24ae9589b 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Discriminator.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Discriminator.java @@ -40,7 +40,10 @@ public interface Discriminator extends Constructible { * @param propertyName the name of the property in the payload that will hold the discriminator value * @return the current Discriminator instance */ - Discriminator propertyName(String propertyName); + default Discriminator propertyName(String propertyName) { + setPropertyName(propertyName); + return this; + } /** * Returns the propertyName property from a Discriminator instance. @@ -71,7 +74,10 @@ public interface Discriminator extends Constructible { * @param mapping a map containing keys and schema names or references * @return the current Discriminator instance */ - Discriminator mapping(Map mapping); + default Discriminator mapping(Map mapping) { + setMapping(mapping); + return this; + } /** * Returns the mapping property from a Discriminator instance. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Encoding.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Encoding.java index 54217e1b0..62b473f9e 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Encoding.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Encoding.java @@ -54,7 +54,10 @@ public String toString() { * @param contentType a string that describes the type of content of the encoding * @return Encoding */ - Encoding contentType(String contentType); + default Encoding contentType(String contentType) { + setContentType(contentType); + return this; + } /** * The Content-Type for encoding a specific property. Default value depends on the property type: i.e. for binary string - contentType is @@ -84,7 +87,10 @@ public String toString() { * @param headers a map of name to corresponding header object * @return Encoding */ - Encoding headers(Map headers); + default Encoding headers(Map headers) { + setHeaders(headers); + return this; + } /** * Headers property of an Encoding is a map that allows additional information to be provided as headers @@ -112,7 +118,10 @@ public String toString() { * @param style a string that descibes how encoding value will be serialized * @return Encoding */ - Encoding style(Style style); + default Encoding style(Style style) { + setStyle(style); + return this; + } /** * Style describes how the encoding value will be serialized depending on the type of the parameter value. @@ -142,7 +151,10 @@ public String toString() { * @param explode a boolean that indicates whether the property values of array or object will generate separate parameters * @return Encoding */ - Encoding explode(Boolean explode); + default Encoding explode(Boolean explode) { + setExplode(explode); + return this; + } /** * When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the @@ -174,7 +186,10 @@ public String toString() { * @param allowReserved a boolean that determines whether the parameter value SHOULD allow reserved characters * @return Encoding */ - Encoding allowReserved(Boolean allowReserved); + default Encoding allowReserved(Boolean allowReserved) { + setAllowReserved(allowReserved); + return this; + } /** * AllowReserved determines whether the parameter value SHOULD allow reserved characters to be encoded without percent-encoding. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/MediaType.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/MediaType.java index f2c39f539..6a358efb2 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/MediaType.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/MediaType.java @@ -54,7 +54,10 @@ public interface MediaType extends Constructible, Extensible { * @param schema the schema defining the type used for the request body * @return the current MediaType instance */ - MediaType schema(Schema schema); + default MediaType schema(Schema schema) { + setSchema(schema); + return this; + } /** * Returns the collection of examples from a MediaType instance. @@ -78,7 +81,10 @@ public interface MediaType extends Constructible, Extensible { * @param examples examples of the media type * @return the current MediaType instance */ - MediaType examples(Map examples); + default MediaType examples(Map examples) { + setExamples(examples); + return this; + } /** * Adds an example item to the examples map of a MediaType instance. The example object should match the media type and specified schema if @@ -112,7 +118,10 @@ public interface MediaType extends Constructible, Extensible { * @param example an example of the media type * @return the current MediaType instance */ - MediaType example(Object example); + default MediaType example(Object example) { + setExample(example); + return this; + } /** * Returns the encoding property from a MediaType instance. @@ -134,7 +143,10 @@ public interface MediaType extends Constructible, Extensible { * @param encoding a map between property names and their encoding information * @return the current MediaType instance */ - MediaType encoding(Map encoding); + default MediaType encoding(Map encoding) { + setEncoding(encoding); + return this; + } /** * Adds an Encoding item to the encoding property of a MediaType instance. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Schema.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Schema.java index ae3ba4eb8..8bfe87b9a 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Schema.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Schema.java @@ -81,7 +81,10 @@ public String toString() { * @param discriminator the object that is used to differentiate between the schemas which may satisfy the payload description * @return the current Schema instance */ - Schema discriminator(Discriminator discriminator); + default Schema discriminator(Discriminator discriminator) { + setDiscriminator(discriminator); + return this; + } /** * Returns the title property from this Schema instance. @@ -103,7 +106,10 @@ public String toString() { * @param title a title to assign to this Schema * @return the current Schema instance */ - Schema title(String title); + default Schema title(String title) { + setTitle(title); + return this; + } /** * Returns the default value property from this Schema instance. @@ -125,7 +131,10 @@ public String toString() { * @param defaultValue a value to use as the default * @return the current Schema instance */ - Schema defaultValue(Object defaultValue); + default Schema defaultValue(Object defaultValue) { + setDefaultValue(defaultValue); + return this; + } /** * Returns the enumerated list of values allowed for objects defined by this Schema. @@ -141,7 +150,10 @@ public String toString() { */ void setEnumeration(List enumeration); - Schema enumeration(List enumeration); + default Schema enumeration(List enumeration) { + setEnumeration(enumeration); + return this; + } /** * Adds an item of the appropriate type to the enumerated list of values allowed. @@ -173,7 +185,10 @@ public String toString() { * @param multipleOf a positive number that restricts the value of objects described by this Schema * @return the current Schema instance */ - Schema multipleOf(BigDecimal multipleOf); + default Schema multipleOf(BigDecimal multipleOf) { + setMultipleOf(multipleOf); + return this; + } /** * Returns the maximum property from this Schema instance. @@ -195,7 +210,10 @@ public String toString() { * @param maximum specifies the maximum numeric value of objects defined by this Schema * @return the current Schema instance */ - Schema maximum(BigDecimal maximum); + default Schema maximum(BigDecimal maximum) { + setMaximum(maximum); + return this; + } /** * Returns the exclusiveMaximum property from this Schema instance. @@ -217,7 +235,10 @@ public String toString() { * @param exclusiveMaximum when true the numeric value of objects defined by this Schema must be less than indicated by the maximum property * @return the current Schema instance */ - Schema exclusiveMaximum(Boolean exclusiveMaximum); + default Schema exclusiveMaximum(Boolean exclusiveMaximum) { + setExclusiveMaximum(exclusiveMaximum); + return this; + } /** * Returns the minimum property from this Schema instance. @@ -239,7 +260,10 @@ public String toString() { * @param minimum specifies the minimum numeric value of objects defined by this Schema * @return the current Schema instance */ - Schema minimum(BigDecimal minimum); + default Schema minimum(BigDecimal minimum) { + setMinimum(minimum); + return this; + } /** * Returns the exclusiveMinimum property from this Schema instance. @@ -261,7 +285,10 @@ public String toString() { * @param exclusiveMinimum when true the numeric value of objects defined by this Schema must be greater than indicated by the minimum property * @return the current Schema instance */ - Schema exclusiveMinimum(Boolean exclusiveMinimum); + default Schema exclusiveMinimum(Boolean exclusiveMinimum) { + setExclusiveMinimum(exclusiveMinimum); + return this; + } /** * Returns the maxLength property from this Schema instance. @@ -285,7 +312,10 @@ public String toString() { * @param maxLength the maximum length of objects defined by this Schema * @return the current Schema instance */ - Schema maxLength(Integer maxLength); + default Schema maxLength(Integer maxLength) { + setMaxLength(maxLength); + return this; + } /** * Returns the minLength property from this Schema instance. @@ -309,7 +339,10 @@ public String toString() { * @param minLength the minimum length of objects defined by this Schema * @return the current Schema instance */ - Schema minLength(Integer minLength); + default Schema minLength(Integer minLength) { + setMinLength(minLength); + return this; + } /** * Returns the pattern property from this Schema instance. @@ -331,7 +364,10 @@ public String toString() { * @param pattern the regular expression which restricts objects defined by this Schema * @return the current Schema instance */ - Schema pattern(String pattern); + default Schema pattern(String pattern) { + setPattern(pattern); + return this; + } /** * Returns the maxItems property from this Schema instance. @@ -355,7 +391,10 @@ public String toString() { * @param maxItems the maximum number of elements in objects defined by this Schema e.g. array elements * @return the current Schema instance */ - Schema maxItems(Integer maxItems); + default Schema maxItems(Integer maxItems) { + setMaxItems(maxItems); + return this; + } /** * Returns the minItems property from this Schema instance. @@ -379,7 +418,10 @@ public String toString() { * @param minItems the minimum number of elements in objects defined by this Schema e.g. array elements * @return the current Schema instance */ - Schema minItems(Integer minItems); + default Schema minItems(Integer minItems) { + setMinItems(minItems); + return this; + } /** * Returns the uniqueItems property from this Schema instance. @@ -401,7 +443,10 @@ public String toString() { * @param uniqueItems ensure the items (e.g. array elements) are unique in objects defined by this Schema * @return the current Schema instance */ - Schema uniqueItems(Boolean uniqueItems); + default Schema uniqueItems(Boolean uniqueItems) { + setUniqueItems(uniqueItems); + return this; + } /** * Returns the maxProperties property from this Schema instance. @@ -425,7 +470,10 @@ public String toString() { * @param maxProperties limit the number of properties in objects defined by this Schema * @return the current Schema instance */ - Schema maxProperties(Integer maxProperties); + default Schema maxProperties(Integer maxProperties) { + setMaxProperties(maxProperties); + return this; + } /** * Returns the minProperties property from this Schema instance. @@ -449,7 +497,10 @@ public String toString() { * @param minProperties limit the number of properties in objects defined by this Schema * @return the current Schema instance */ - Schema minProperties(Integer minProperties); + default Schema minProperties(Integer minProperties) { + setMinProperties(minProperties); + return this; + } /** * Returns the required property from this Schema instance. @@ -471,7 +522,10 @@ public String toString() { * @param required the list of fields required in objects defined by this Schema * @return the current Schema instance */ - Schema required(List required); + default Schema required(List required) { + setRequired(required); + return this; + } /** * Adds the name of an item to the list of fields required in objects defined by this Schema. @@ -503,7 +557,10 @@ public String toString() { * reference schemas * @return the current Schema instance */ - Schema type(SchemaType type); + default Schema type(SchemaType type) { + setType(type); + return this; + } /** * Returns a Schema which describes properties not allowed in objects defined by the current schema. @@ -525,7 +582,10 @@ public String toString() { * @param not the Schema which describes properties not allowed * @return the current Schema instance */ - Schema not(Schema not); + default Schema not(Schema not) { + setNot(not); + return this; + } /** * Returns the properties defined in this Schema. @@ -547,7 +607,10 @@ public String toString() { * @param properties a map which associates property names with the schemas that describe their contents * @return the current Schema instance */ - Schema properties(Map properties); + default Schema properties(Map properties) { + setProperties(properties); + return this; + } /** * Adds a Schema property of the provided name using the given schema. @@ -635,7 +698,10 @@ public String toString() { * @param description a string containing a description of the purpose of this Schema * @return the current Schema instance */ - Schema description(String description); + default Schema description(String description) { + setDescription(description); + return this; + } /** * Returns the format property from this Schema instance. This property clarifies the data type specified in the type property. @@ -659,7 +725,10 @@ public String toString() { * @param format the string specifying the data format * @return the current Schema instance */ - Schema format(String format); + default Schema format(String format) { + setFormat(format); + return this; + } /** * Returns the nullable property from this Schema instance which indicates whether null is a valid value. @@ -681,7 +750,10 @@ public String toString() { * @param nullable a boolean value indicating this Schema allows a null value. * @return the current Schema instance */ - Schema nullable(Boolean nullable); + default Schema nullable(Boolean nullable) { + setNullable(nullable); + return this; + } /** * Returns the readOnly property from this Schema instance. @@ -703,7 +775,10 @@ public String toString() { * @param readOnly true indicates the Schema should not be sent as part of a request message * @return the current Schema instance */ - Schema readOnly(Boolean readOnly); + default Schema readOnly(Boolean readOnly) { + setReadOnly(readOnly); + return this; + } /** * Returns the writeOnly property from this Schema instance. @@ -725,7 +800,10 @@ public String toString() { * @param writeOnly true indicates the Schema should not be sent as part of a response message * @return the current Schema instance */ - Schema writeOnly(Boolean writeOnly); + default Schema writeOnly(Boolean writeOnly) { + setWriteOnly(writeOnly); + return this; + } /** * Returns the example property from this Schema instance. @@ -749,7 +827,10 @@ public String toString() { * @param example an object which is an instance of this Schema * @return the current Schema instance */ - Schema example(Object example); + default Schema example(Object example) { + setExample(example); + return this; + } /** * Returns the externalDocs property from this Schema instance. @@ -771,7 +852,10 @@ public String toString() { * @param externalDocs an additional external documentation object * @return the current Schema instance */ - Schema externalDocs(ExternalDocumentation externalDocs); + default Schema externalDocs(ExternalDocumentation externalDocs) { + setExternalDocs(externalDocs); + return this; + } /** * Returns the deprecated property from this Schema instance. @@ -793,7 +877,10 @@ public String toString() { * @param deprecated true to indicate this Schema is deprecated * @return the current Schema instance */ - Schema deprecated(Boolean deprecated); + default Schema deprecated(Boolean deprecated) { + setDeprecated(deprecated); + return this; + } /** * Returns the xml property from this Schema instance. @@ -817,7 +904,10 @@ public String toString() { * @param xml a metadata object to describe the XML representation of this property * @return the current Schema instance */ - Schema xml(XML xml); + default Schema xml(XML xml) { + setXml(xml); + return this; + } /** @@ -840,7 +930,10 @@ public String toString() { * @param items the Schema used by this array * @return the current Schema instance */ - Schema items(Schema items); + default Schema items(Schema items) { + setItems(items); + return this; + } /** * Returns the schemas used by the allOf property. @@ -862,7 +955,10 @@ public String toString() { * @param allOf the list of schemas used by the allOf property * @return the current Schema instance */ - Schema allOf(List allOf); + default Schema allOf(List allOf) { + setAllOf(allOf); + return this; + } /** * Adds the given Schema to the list of schemas used by the allOf property. @@ -892,7 +988,10 @@ public String toString() { * @param anyOf the list of schemas used by the anyOf property * @return the current Schema instance */ - Schema anyOf(List anyOf); + default Schema anyOf(List anyOf) { + setAnyOf(anyOf); + return this; + } /** * Adds the given Schema to the list of schemas used by the anyOf property. @@ -922,7 +1021,10 @@ public String toString() { * @param oneOf the list of schemas used by the oneOf property * @return the current Schema instance */ - Schema oneOf(List oneOf); + default Schema oneOf(List oneOf) { + setOneOf(oneOf); + return this; + } /** * Adds the given Schema to the list of schemas used by the oneOf property. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/XML.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/XML.java index 5b6df7fed..d9082b1b2 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/media/XML.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/media/XML.java @@ -55,7 +55,10 @@ public interface XML extends Constructible, Extensible { * @param name the name of this XML instance * @return XML instance with the set name property */ - XML name(String name); + default XML name(String name) { + setName(name); + return this; + } /** * This method returns the namespace property of XML instance. @@ -83,7 +86,10 @@ public interface XML extends Constructible, Extensible { * @param namespace the URI of the namespace definition * @return XML instance with the set namespace property */ - XML namespace(String namespace); + default XML namespace(String namespace) { + setNamespace(namespace); + return this; + } /** * This method returns the prefix property of XML instance. @@ -111,7 +117,10 @@ public interface XML extends Constructible, Extensible { * @param prefix string prefix to be used with the name * @return XML instance with the set prefix property */ - XML prefix(String prefix); + default XML prefix(String prefix) { + setPrefix(prefix); + return this; + } /** * This method returns the attribute property of XML instance. @@ -139,7 +148,10 @@ public interface XML extends Constructible, Extensible { * @param attribute a boolean that declares whether the property definition translates to an attribute instead of an element * @return XML instance with the set attribute property */ - XML attribute(Boolean attribute); + default XML attribute(Boolean attribute) { + setAttribute(attribute); + return this; + } /** * This method returns the wrapped property of XML instance. @@ -170,6 +182,9 @@ public interface XML extends Constructible, Extensible { * @param wrapped a boolean that signifies whether the array is wrapped * @return XML instance with the set wrapped property */ - XML wrapped(Boolean wrapped); + default XML wrapped(Boolean wrapped) { + setWrapped(wrapped); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/Parameter.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/Parameter.java index eff083374..0a5144065 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/Parameter.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/Parameter.java @@ -109,7 +109,10 @@ public String toString() { * @param name the name of the parameter * @return the current Parameter instance */ - Parameter name(String name); + default Parameter name(String name) { + setName(name); + return this; + } /** * Returns the in property from a Parameter instance. @@ -131,7 +134,10 @@ public String toString() { * @param in the value of the in property * @return the current Parameter instance */ - Parameter in(In in); + default Parameter in(In in) { + setIn(in); + return this; + } /** * Returns the description property from a Parameter instance. @@ -153,7 +159,10 @@ public String toString() { * @param description a brief description of the parameter * @return the current Parameter instance */ - Parameter description(String description); + default Parameter description(String description) { + setDescription(description); + return this; + } /** * Returns the required property from a Parameter instance. @@ -175,7 +184,10 @@ public String toString() { * @param required indicates whether this parameter is mandatory * @return the current Parameter instance */ - Parameter required(Boolean required); + default Parameter required(Boolean required) { + setRequired(required); + return this; + } /** * Returns the deprecated property from a Parameter instance. @@ -197,7 +209,10 @@ public String toString() { * @param deprecated specifies that a parameter is deprecated * @return the current Parameter instance */ - Parameter deprecated(Boolean deprecated); + default Parameter deprecated(Boolean deprecated) { + setDeprecated(deprecated); + return this; + } /** * Returns the allowEmptyValue property from a Parameter instance. @@ -219,7 +234,10 @@ public String toString() { * @param allowEmptyValue specify the ability to pass empty-valued parameters * @return the current Parameter instance */ - Parameter allowEmptyValue(Boolean allowEmptyValue); + default Parameter allowEmptyValue(Boolean allowEmptyValue) { + setAllowEmptyValue(allowEmptyValue); + return this; + } /** * Returns the style property from a Parameter instance. @@ -241,7 +259,10 @@ public String toString() { * @param style describes how the parameter value will be serialized * @return the current Parameter instance */ - Parameter style(Parameter.Style style); + default Parameter style(Parameter.Style style) { + setStyle(style); + return this; + } /** * Returns the explode property from a Parameter instance. @@ -263,7 +284,10 @@ public String toString() { * @param explode whether parameter values of type "array" or "object" generate separate parameters for each value * @return the current Parameter instance */ - Parameter explode(Boolean explode); + default Parameter explode(Boolean explode) { + setExplode(explode); + return this; + } /** * Returns the allowReserved property from a Parameter instance. @@ -285,7 +309,10 @@ public String toString() { * @param allowReserved specifies whether the parameter value should allow reserved characters * @return the current Parameter instance */ - Parameter allowReserved(Boolean allowReserved); + default Parameter allowReserved(Boolean allowReserved) { + setAllowReserved(allowReserved); + return this; + } /** * Returns the schema property from a Parameter instance. @@ -307,7 +334,10 @@ public String toString() { * @param schema schema defining the type used for the parameter * @return the current Parameter instance */ - Parameter schema(Schema schema); + default Parameter schema(Schema schema) { + setSchema(schema); + return this; + } /** * Returns the examples property from a Parameter instance. @@ -331,7 +361,10 @@ public String toString() { * @param examples examples of the media type * @return the current Parameter instance */ - Parameter examples(Map examples); + default Parameter examples(Map examples) { + setExamples(examples); + return this; + } /** * Adds an example of the media type using the specified key. The example should contain a value in the correct format as specified in the @@ -365,7 +398,10 @@ public String toString() { * @param example example of the media type * @return the current Parameter instance */ - Parameter example(Object example); + default Parameter example(Object example) { + setExample(example); + return this; + } /** * Returns the content property from a Parameter instance. @@ -387,6 +423,9 @@ public String toString() { * @param content a map containing the media representations for the parameter * @return the current Parameter instance */ - Parameter content(Content content); + default Parameter content(Content content) { + setContent(content); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/RequestBody.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/RequestBody.java index ef5b91c93..3f97d79a7 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/RequestBody.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/parameters/RequestBody.java @@ -52,7 +52,10 @@ public interface RequestBody extends Constructible, Extensible, Reference headers); + default APIResponse headers(Map headers) { + setHeaders(headers); + return this; + } /** * Adds the given Header to this ApiResponse instance's map of Headers with the given name and return this instance of ApiResponse. If this @@ -119,7 +125,10 @@ public interface APIResponse extends Constructible, Extensible, Reference links); + default APIResponse links(Map links) { + setLinks(links); + return this; + } /** * Adds a link to this instance of ApiResponse using the given name and Link, and returns this ApiResponse instance. diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/responses/APIResponses.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/responses/APIResponses.java index 6a6ab6744..b297f5a65 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/responses/APIResponses.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/responses/APIResponses.java @@ -64,6 +64,9 @@ public interface APIResponses extends Constructible, Map { * @return this ApiResponses instance */ - APIResponses defaultValue(APIResponse defaultValue); + default APIResponses defaultValue(APIResponse defaultValue) { + setDefaultValue(defaultValue); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlow.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlow.java index b2eb4fb3d..2e3f75877 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlow.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlow.java @@ -59,7 +59,10 @@ public interface OAuthFlow extends Constructible, Extensible { * @param authorizationUrl the authorization URL used for this flow * @return OAuthFlow instance with the set authorizationUrl property */ - OAuthFlow authorizationUrl(String authorizationUrl); + default OAuthFlow authorizationUrl(String authorizationUrl) { + setAuthorizationUrl(authorizationUrl); + return this; + } /** * The token URL to be used for this flow. This MUST be in the form of a URL. This is a REQUIRED property. @@ -93,7 +96,10 @@ public interface OAuthFlow extends Constructible, Extensible { * @param tokenUrl the token URL to be used for this flow * @return OAuthFlow instance with the set tokenUrl property */ - OAuthFlow tokenUrl(String tokenUrl); + default OAuthFlow tokenUrl(String tokenUrl) { + setTokenUrl(tokenUrl); + return this; + } /** * The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. @@ -127,7 +133,10 @@ public interface OAuthFlow extends Constructible, Extensible { * @param refreshUrl the URL to be used for obtaining refresh tokens * @return OAuthFlow instance with the set refreshUrl property */ - OAuthFlow refreshUrl(String refreshUrl); + default OAuthFlow refreshUrl(String refreshUrl) { + setRefreshUrl(refreshUrl); + return this; + } /** * The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. This is a REQUIRED property. @@ -161,6 +170,9 @@ public interface OAuthFlow extends Constructible, Extensible { * @param scopes the available scopes for the OAuth2 security scheme * @return OAuthFlow instance with the set scopes property */ - OAuthFlow scopes(Scopes scopes); + default OAuthFlow scopes(Scopes scopes) { + setScopes(scopes); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlows.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlows.java index 522e694f6..8bd498d66 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlows.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/security/OAuthFlows.java @@ -47,7 +47,10 @@ public interface OAuthFlows extends Constructible, Extensible { * @param implicit the OauthFlow instance * @return OAuthFlows instance with the set implicit property */ - OAuthFlows implicit(OAuthFlow implicit); + default OAuthFlows implicit(OAuthFlow implicit) { + setImplicit(implicit); + return this; + } /** * OAuth Resource Owner Password flow @@ -75,7 +78,10 @@ public interface OAuthFlows extends Constructible, Extensible { * @param password the OauthFlow instance * @return OAuthFlows instance with the set password property */ - OAuthFlows password(OAuthFlow password); + default OAuthFlows password(OAuthFlow password) { + setPassword(password); + return this; + } /** * OAuth Client Credential flow; previously called application in OpenAPI 2.0 @@ -104,7 +110,10 @@ public interface OAuthFlows extends Constructible, Extensible { * @param clientCredentials the OauthFlow instance * @return OAuthFlows instance with the set clientCredentials property */ - OAuthFlows clientCredentials(OAuthFlow clientCredentials); + default OAuthFlows clientCredentials(OAuthFlow clientCredentials) { + setClientCredentials(clientCredentials); + return this; + } /** * OAuth Authorization Code flow; previously called accessCode in OpenAPI 2.0 @@ -133,6 +142,9 @@ public interface OAuthFlows extends Constructible, Extensible { * @param authorizationCode the OauthFlow instance * @return OAuthFlows instance with the set authorizationCode property */ - OAuthFlows authorizationCode(OAuthFlow authorizationCode); + default OAuthFlows authorizationCode(OAuthFlow authorizationCode) { + setAuthorizationCode(authorizationCode); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/security/SecurityScheme.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/security/SecurityScheme.java index 2127a5c24..e1c3b4e17 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/security/SecurityScheme.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/security/SecurityScheme.java @@ -96,7 +96,10 @@ public String toString() { * @param type the type of SecurityScheme instance * @return SecurityScheme instance with the set type property */ - SecurityScheme type(SecurityScheme.Type type); + default SecurityScheme type(SecurityScheme.Type type) { + setType(type); + return this; + } /** * A short description for security schema. @@ -124,7 +127,10 @@ public String toString() { * @param description short description of the SecuirtyScheme instance * @return SecurityScheme instance with the set description property */ - SecurityScheme description(String description); + default SecurityScheme description(String description) { + setDescription(description); + return this; + } /** * Name is a REQUIRED property - this is the name of the header, query or cookie parameter to be used. @@ -152,7 +158,10 @@ public String toString() { * @param name the name of the header, query or cookie parameter to be used * @return SecurityScheme instance with the set name property */ - SecurityScheme name(String name); + default SecurityScheme name(String name) { + setName(name); + return this; + } /** * In is a REQUIRED property that indicates the location of the API key. Valid values are "query", "header", "cookie". @@ -180,7 +189,10 @@ public String toString() { * @param in the location of the API key * @return SecurityScheme instance with the set in property */ - SecurityScheme in(SecurityScheme.In in); + default SecurityScheme in(SecurityScheme.In in) { + setIn(in); + return this; + } /** * Schema is a REQUIRED property that is the name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. @@ -208,7 +220,10 @@ public String toString() { * @param scheme the name of the HTTP Authorization scheme to be used in the Authorization header * @return SecurityScheme instance with the set scheme property */ - SecurityScheme scheme(String scheme); + default SecurityScheme scheme(String scheme) { + setScheme(scheme); + return this; + } /** * bearerFormat is intended as a hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an @@ -239,7 +254,10 @@ public String toString() { * @param bearerFormat a hint to the client to identify how the bearer token is formatted * @return SecurityScheme instance with the set bearerFormat property */ - SecurityScheme bearerFormat(String bearerFormat); + default SecurityScheme bearerFormat(String bearerFormat) { + setBearerFormat(bearerFormat); + return this; + } /** * Flows is a REQUIRED property. @@ -276,7 +294,10 @@ public String toString() { * @param flows an object containing configuration information for the flow types supported * @return SecurityScheme instance with the set flows property */ - SecurityScheme flows(OAuthFlows flows); + default SecurityScheme flows(OAuthFlows flows) { + setFlows(flows); + return this; + } /** * openIdConnectUrl is a REQUIRED property. @@ -313,6 +334,9 @@ public String toString() { * @param openIdConnectUrl a URL where OAuth2 configuration values are stored * @return SecurityScheme instance with the set openIdConnectUrl property */ - SecurityScheme openIdConnectUrl(String openIdConnectUrl); + default SecurityScheme openIdConnectUrl(String openIdConnectUrl) { + setOpenIdConnectUrl(openIdConnectUrl); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/Server.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/Server.java index e1936bcbf..be260a264 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/Server.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/Server.java @@ -66,7 +66,10 @@ public interface Server extends Constructible, Extensible { * @param url a URL to the target host * @return Server instance with the set url property. */ - Server url(String url); + default Server url(String url) { + setUrl(url); + return this; + } /** * This method returns the description property of Server instance. The decsription property is an optional string describing the host designated @@ -94,7 +97,10 @@ public interface Server extends Constructible, Extensible { * @param description an optional string describing the host designated by the URL * @return Server instance with the set description property. */ - Server description(String description); + default Server description(String description) { + setDescription(description); + return this; + } /** * This method returns the variables property of Server instance. @@ -122,6 +128,9 @@ public interface Server extends Constructible, Extensible { * @param variables a map between variable name and its value * @return Server instance with the set variables property. */ - Server variables(ServerVariables variables); + default Server variables(ServerVariables variables) { + setVariables(variables); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/ServerVariable.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/ServerVariable.java index 5c393be8d..db161ade3 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/ServerVariable.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/servers/ServerVariable.java @@ -55,7 +55,10 @@ public interface ServerVariable extends Constructible, Extensible { * @param enumeration an list of string values to be used if the substitution options are from a limited set * @return ServerVariable instance with the set enumeration property */ - ServerVariable enumeration(List enumeration); + default ServerVariable enumeration(List enumeration) { + setEnumeration(enumeration); + return this; + } /** * This method adds a string item to enumeration list of a ServerVariable instance and returns the instance. @@ -97,7 +100,10 @@ public interface ServerVariable extends Constructible, Extensible { * @return ServerVariable instance with the set defaultValue property */ - ServerVariable defaultValue(String defaultValue); + default ServerVariable defaultValue(String defaultValue) { + setDefaultValue(defaultValue); + return this; + } /** * This method returns the description property of ServerVariable instance. Description property is optional for server variable. @@ -122,6 +128,9 @@ public interface ServerVariable extends Constructible, Extensible { * @param description a short description of the server variable * @return ServerVariable instance with the set description property */ - ServerVariable description(String description); + default ServerVariable description(String description) { + setDescription(description); + return this; + } } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/models/tags/Tag.java b/api/src/main/java/org/eclipse/microprofile/openapi/models/tags/Tag.java index 4a983752a..780f69914 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/models/tags/Tag.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/models/tags/Tag.java @@ -50,7 +50,10 @@ public interface Tag extends Constructible, Extensible { * @param name the name property for this tag * @return the current Tag instance */ - Tag name(String name); + default Tag name(String name) { + setName(name); + return this; + } /** * Returns the description property from a Tag instance. @@ -72,7 +75,10 @@ public interface Tag extends Constructible, Extensible { * @param description the description property for this tag * @return the current Tag instance */ - Tag description(String description); + default Tag description(String description) { + setDescription(description); + return this; + } /** * Returns the externalDocs property from a Tag instance. @@ -94,6 +100,9 @@ public interface Tag extends Constructible, Extensible { * @param externalDocs additional external documentation for this tag * @return the current Tag instance */ - Tag externalDocs(ExternalDocumentation externalDocs); + default Tag externalDocs(ExternalDocumentation externalDocs) { + setExternalDocs(externalDocs); + return this; + } } \ No newline at end of file