Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default values #139

Merged
merged 20 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
55a4d0c
feat: AsyncAPI default values for @NotNull fields
Pakisan Mar 17, 2023
bdf61f8
feat: Tag default values for @NotNull fields
Pakisan Mar 17, 2023
23219b3
feat: Reference default values for @NotNull fields
Pakisan Mar 17, 2023
be23dd0
feat: ExternalDocumentation default values for @NotNull fields
Pakisan Mar 17, 2023
59aa6a3
feat: Server default values for @NotNull fields
Pakisan Mar 17, 2023
109fde7
feat: Info default values for @NotNull fields
Pakisan Mar 17, 2023
cd84266
feat: License default values for @NotNull fields
Pakisan Mar 17, 2023
b336177
feat: CorrelationId default values for @NotNull fields
Pakisan Mar 17, 2023
8361ecc
feat: OneOfMessages default values for @NotNull fields
Pakisan Mar 17, 2023
3976097
feat: OpenIdConnectSecurityScheme default values for @NotNull fields
Pakisan Mar 17, 2023
6a65fb4
feat: ApiKeySecurityScheme default values for @NotNull fields
Pakisan Mar 17, 2023
36aa94c
feat: SecurityScheme default values for @NotNull fields
Pakisan Mar 17, 2023
9c76d44
feat: OAuth2SecurityScheme default values for @NotNull fields
Pakisan Mar 17, 2023
aba01dc
feat: AuthorizationCodeOAuthFlow default values for @NotNull fields
Pakisan Mar 17, 2023
d9af9b2
feat: ClientCredentialsOAuthFlow default values for @NotNull fields
Pakisan Mar 17, 2023
d32ee63
feat: ImplicitOAuthFlow default values for @NotNull fields
Pakisan Mar 17, 2023
5c90b82
feat: OAuthFlow default values for @NotNull fields
Pakisan Mar 17, 2023
91a3142
feat: PasswordOAuthFlow default values for @NotNull fields
Pakisan Mar 17, 2023
ae69a30
feat: HttpApiKeySecurityScheme default values for @NotNull fields
Pakisan Mar 17, 2023
e597d48
feat: HttpSecurityScheme default values for @NotNull fields
Pakisan Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -44,7 +45,8 @@ public class AsyncAPI extends ExtendableObject {
* Patch versions will correspond to patches of this document.
*/
@NotNull
private String asyncapi = "2.0.0";
@Builder.Default
private final String asyncapi = "2.0.0";

/**
* Identifier of the application the AsyncAPI document is defining.
Expand Down Expand Up @@ -74,7 +76,8 @@ public class AsyncAPI extends ExtendableObject {
* Provides metadata about the API. The metadata can be used by the clients if needed.
*/
@NotNull
private Info info;
@Builder.Default
private Info info = new Info();

/**
* Provides connection details of servers.
Expand All @@ -92,7 +95,8 @@ public class AsyncAPI extends ExtendableObject {
* Channels are also known as "topics", "routing keys", "event types" or "paths".
*/
@NotNull
private Map<String, ChannelItem> channels;
@Builder.Default
private Map<String, ChannelItem> channels = new HashMap<>();

/**
* An element to hold various schemas for the specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ExternalDocumentation extends ExtendableObject {
* The URL for the target documentation. Value MUST be in the format of a URL.
*/
@NotNull
private String url;
@Builder.Default
private String url = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public class Reference {
*/
@NotNull
@JsonProperty(value = "$ref")
private String ref;
private String ref = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class Tag extends ExtendableObject {
* Required. The name of the tag.
*/
@NotNull
private String name;
@Builder.Default
private String name = "";

/**
* A short description for the tag. CommonMark syntax can be used for rich text representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class CorrelationId extends ExtendableObject {
* A runtime expression that specifies the location of the correlation ID.
*/
@NotNull
private String location;
@Builder.Default
private String location = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class Info extends ExtendableObject {
*/
@NotNull
@JsonProperty
private String title;
@Builder.Default
private String title = "";

/**
* Required.
Expand All @@ -40,7 +41,8 @@ public class Info extends ExtendableObject {
*/
@NotNull
@JsonProperty
private String version;
@Builder.Default
private String version = "";

/**
* A short description of the application. CommonMark syntax can be used for rich text representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class License extends ExtendableObject {
* Required. The license name used for the API.
*/
@NotNull
private String name;
@Builder.Default
private String name = "";

/**
* A URL to the license used for the API. MUST be in the format of a URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class Server extends ExtendableObject {
*/
@NotNull
@JsonProperty
private String url;
@Builder.Default
private String url = "";

/**
* REQUIRED.
Expand All @@ -52,7 +53,8 @@ public class Server extends ExtendableObject {
*/
@NotNull
@JsonProperty
private String protocol;
@Builder.Default
private String protocol = "";

/**
* The version of the protocol used for connection. For instance: AMQP 0.9.1, HTTP 2.0, Kafka 1.0.0, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -44,7 +45,8 @@ public class AsyncAPI extends ExtendableObject {
* Patch versions will correspond to patches of this document.
*/
@NotNull
private String asyncapi = "2.6.0";
@Builder.Default
private final String asyncapi = "2.6.0";

/**
* Identifier of the application the AsyncAPI document is defining.
Expand All @@ -64,7 +66,8 @@ public class AsyncAPI extends ExtendableObject {
* Provides metadata about the API. The metadata can be used by the clients if needed.
*/
@NotNull
private Info info;
@Builder.Default
private Info info = new Info();

/**
* TODO: references
Expand Down Expand Up @@ -93,7 +96,8 @@ public class AsyncAPI extends ExtendableObject {
* Channels are also known as "topics", "routing keys", "event types" or "paths".
*/
@NotNull
private Map<String, ChannelItem> channels;
@Builder.Default
private Map<String, ChannelItem> channels = new HashMap<>();

/**
* An element to hold various schemas for the specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ExternalDocumentation extends ExtendableObject {
* The URL for the target documentation. Value MUST be in the format of a URL.
*/
@NotNull
private String url;
@Builder.Default
private String url = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public class Reference {
*/
@NotNull
@JsonProperty(value = "$ref")
private String ref;
private String ref = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class Tag extends ExtendableObject {
* Required. The name of the tag.
*/
@NotNull
private String name;
@Builder.Default
private String name = "";

/**
* A short description for the tag. <a href="https://spec.commonmark.org/">CommonMark syntax</a> can be used for rich text representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class CorrelationId extends ExtendableObject {
* A <a href="https://www.asyncapi.com/docs/reference/specification/v2.6.0#runtimeExpression">runtime expression</a> that specifies the location of the correlation ID.
*/
@NotNull
private String location;
@Builder.Default
private String location = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.util.LinkedList;
import java.util.List;

/**
Expand All @@ -30,7 +31,8 @@ public class OneOfMessages {
* </ul>
*/
@NotNull
@Builder.Default
@JsonDeserialize(using = MessagesDeserializer.class)
private List<Object> oneOf;
private List<Object> oneOf = new LinkedList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ public class Info extends ExtendableObject {
* The title of the application.
*/
@NotNull
private String title;
@Builder.Default
private String title = "";

/**
* Required.
* <p>
* Provides the version of the application API (not to be confused with the specification version).
*/
@NotNull
private String version;
@Builder.Default
private String version = "";

/**
* A short description of the application. CommonMark syntax can be used for rich text representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class License extends ExtendableObject {
* Required. The license name used for the API.
*/
@NotNull
private String name;
@Builder.Default
private String name = "";

/**
* A URL to the license used for the API. MUST be in the format of a URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class Server extends ExtendableObject {
* made when a variable is named in {brackets}.
*/
@NotNull
private String url;
@Builder.Default
private String url = "";

/**
* REQUIRED.
Expand All @@ -51,7 +52,8 @@ public class Server extends ExtendableObject {
* amqp, amqps, http, https, ibmmq, jms, kafka, kafka-secure, anypointmq, mqtt, secure-mqtt, solace, stomp, stomps, ws, wss, mercure, googlepubsub, pulsar.
*/
@NotNull
private String protocol;
@Builder.Default
private String protocol = "";

/**
* The version of the protocol used for connection. For instance: AMQP 0.9.1, HTTP 2.0, Kafka 1.0.0, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ApiKeySecurityScheme extends SecurityScheme {
* The location of the API key.
*/
@NotNull
private ApiKeyLocation in;
private ApiKeyLocation in = ApiKeyLocation.USER;

@Builder(builderMethodName = "apiKeySecuritySchemeBuilder")
public ApiKeySecurityScheme(@NotNull Type type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class OpenIdConnectSecurityScheme extends SecurityScheme {
* OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL.
*/
@NotNull
private String openIdConnectUrl;
private String openIdConnectUrl = "";

@Builder(builderMethodName = "openIdConnectSecurityScheme")
public OpenIdConnectSecurityScheme(@NotNull Type type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class SecurityScheme extends ExtendableObject {
* </ul>
*/
@NotNull
private Type type;
private Type type = Type.USER_PASSWORD;

/**
* A short description for security scheme. <a href="http://spec.commonmark.org/">CommonMark syntax</a> MAY be used for rich text representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class HttpApiKeySecurityScheme extends SecurityScheme {
* The name of the header, query or cookie parameter to be used.
*/
@NotNull
private String name;
private String name = "";

/**
* REQUIRED.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class HttpSecurityScheme extends SecurityScheme {
* The name of the HTTP Authorization scheme to be used in the <a href="https://tools.ietf.org/html/rfc7235#section-5.1">Authorization header as defined in RFC7235</a>.
*/
@NotNull
private String scheme;
private String scheme = "";

/**
* A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class OAuth2SecurityScheme extends SecurityScheme {
* An object containing configuration information for the flow types supported.
*/
@NotNull
private OAuthFlows flows;
private OAuthFlows flows = new OAuthFlows();

@Builder(builderMethodName = "oauth2SecuritySchemeBuilder")
public OAuth2SecurityScheme(@NotNull Type type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public class AuthorizationCodeOAuthFlow extends OAuthFlow {
* The authorization URL to be used for this flow. This MUST be in the form of an absolute URL.
*/
@NotNull
private String authorizationUrl;
private String authorizationUrl = "";

/**
* REQUIRED.
* <p>
* The token URL to be used for this flow. This MUST be in the form of an absolute URL.
*/
@NotNull
private String tokenUrl;
private String tokenUrl = "";

@Builder(builderMethodName = "authorizationCodeOAuthFlowBuilder")
public AuthorizationCodeOAuthFlow(@Nullable String refreshUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ClientCredentialsOAuthFlow extends OAuthFlow {
* The token URL to be used for this flow. This MUST be in the form of a URL.
*/
@NotNull
private String tokenUrl;
private String tokenUrl = "";

@Builder(builderMethodName = "clientCredentialsOAuthFlowBuilder")
public ClientCredentialsOAuthFlow(@Nullable String refreshUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ImplicitOAuthFlow extends OAuthFlow {
* The authorization URL to be used for this flow. This MUST be in the form of a URL
*/
@NotNull
private String authorizationUrl;
private String authorizationUrl = "";

@Builder(builderMethodName = "implicitOAuthFlowBuilder")
public ImplicitOAuthFlow(@Nullable String refreshUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;

/**
Expand All @@ -31,14 +32,14 @@ public class OAuthFlow extends ExtendableObject {
* The URL to be used for obtaining refresh tokens. This MUST be in the form of an absolute URL.
*/
@Nullable
private String refreshUrl;
private String refreshUrl = "";

/**
* REQUIRED.
* <p>
* The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it.
*/
@NotNull
private Map<String, String> scopes;
private Map<String, String> scopes = new HashMap<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class PasswordOAuthFlow extends OAuthFlow {
* The token URL to be used for this flow. This MUST be in the form of a URL.
*/
@NotNull
private String tokenUrl;
private String tokenUrl = "";

@Builder(builderMethodName = "passwordOAuthFlowBuilder")
public PasswordOAuthFlow(@Nullable String refreshUrl,
Expand Down