Skip to content

Commit

Permalink
feat(bindings): WebSocket 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Apr 24, 2024
1 parent ce0f3aa commit d29ad69
Show file tree
Hide file tree
Showing 143 changed files with 5,818 additions and 28,672 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.asyncapi.bindings;

import com.asyncapi.ExtendableObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.Nullable;

/**
* Describes protocol-specific definition for a channel.
Expand All @@ -13,6 +16,17 @@
* @author Pavel Bodiachevskii
* @version 3.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ChannelBinding extends ExtendableObject {

/**
* The version of this binding.
* <p>
* If omitted, 'latest' <b>MUST</b> be assumed.
*/
@Nullable
@JsonProperty("bindingVersion")
private String bindingVersion;

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package com.asyncapi.bindings;

import com.asyncapi.ExtendableObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.Nullable;

/**
* Describes AsyncAPI message binding.
*
* @author Pavel Bodiachevskii
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MessageBinding extends ExtendableObject {

/**
* The version of this binding.
* <p>
* If omitted, 'latest' <b>MUST</b> be assumed.
*/
@Nullable
@JsonProperty("bindingVersion")
private String bindingVersion;

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.asyncapi.bindings;

import com.asyncapi.ExtendableObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.Nullable;

/**
* Describes protocol-specific definition for an operation.
Expand All @@ -13,6 +16,17 @@
* @author Pavel Bodiachevskii
* @version 3.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OperationBinding extends ExtendableObject {

/**
* The version of this binding.
* <p>
* If omitted, 'latest' <b>MUST</b> be assumed.
*/
@Nullable
@JsonProperty("bindingVersion")
private String bindingVersion;

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.asyncapi.bindings;

import com.asyncapi.ExtendableObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.Nullable;

/**
* Describes protocol-specific definition for a server.
Expand All @@ -13,6 +16,17 @@
* @author Pavel Bodiachevskii
* @version 3.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ServerBinding extends ExtendableObject {

/**
* The version of this binding.
* <p>
* If omitted, 'latest' <b>MUST</b> be assumed.
*/
@Nullable
@JsonProperty("bindingVersion")
private String bindingVersion;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.asyncapi.bindings.websockets;

import com.asyncapi.bindings.ChannelBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* Describes WebSockets channel binding.
* <p>
* When using WebSockets, the channel represents the connection.
* <p>
* Unlike other protocols that support multiple virtual channels (topics, routing keys, etc.) per connection,
* WebSockets doesn't support virtual channels or, put it another way, there's only one channel and its characteristics
* are strongly related to the protocol used for the handshake, i.e., HTTP.
*
* @version 0.1.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/websockets#channel-binding-object">WebSockets channel binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.websockets.v0._1_0.channel.WebSocketsChannelBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.websockets.v0._1_0.channel.WebSocketsChannelBinding.class, names = {
"0.1.0",
"latest"
}),
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class WebSocketsChannelBinding extends ChannelBinding {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.asyncapi.bindings.websockets;

import com.asyncapi.bindings.MessageBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* This class <b>MUST NOT</b> contain any properties.
* <p>
* Its name is reserved for future use.
* <p>
* Describes WebSockets message binding.
*
* @version 0.1.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/websockets#message-binding-object">WebSockets message binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.websockets.v0._1_0.message.WebSocketsMessageBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.websockets.v0._1_0.message.WebSocketsMessageBinding.class, names = {
"0.1.0",
"latest"
}),
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class WebSocketsMessageBinding extends MessageBinding {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.asyncapi.bindings.websockets;

import com.asyncapi.bindings.OperationBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* This class <b>MUST NOT</b> contain any properties.
* <p>
* Its name is reserved for future use.
* <p>
* Describes WebSockets operation binding.
*
* @version 0.1.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/websockets#operation-binding-object">WebSockets operation binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.websockets.v0._1_0.operation.WebSocketsOperationBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.websockets.v0._1_0.operation.WebSocketsOperationBinding.class, names = {
"0.1.0",
"latest"
}),
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class WebSocketsOperationBinding extends OperationBinding {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.asyncapi.bindings.websockets;

import com.asyncapi.bindings.ServerBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* This class <b>MUST NOT</b> contain any properties.
* <p>
* Its name is reserved for future use.
* <p>
* Describes WebSockets server binding.
*
* @version 0.1.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/websockets#server-binding-object">WebSockets server binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.websockets.v0._1_0.server.WebSocketsServerBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.websockets.v0._1_0.server.WebSocketsServerBinding.class, names = {
"0.1.0",
"latest"
}),
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class WebSocketsServerBinding extends ServerBinding {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.asyncapi.bindings.websockets.v0._1_0.channel;

import com.asyncapi.bindings.ChannelBinding;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

/**
* Describes WebSockets channel binding.
* <p>
Expand All @@ -22,12 +26,22 @@
* @author Pavel Bodiachevskii
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@JsonClassDescription("Describes WebSockets channel binding.")
public class WebSocketsChannelBinding extends ChannelBinding {
public class WebSocketsChannelBinding extends com.asyncapi.bindings.websockets.WebSocketsChannelBinding {

public WebSocketsChannelBinding() {
this.setBindingVersion("0.1.0");
}

public WebSocketsChannelBinding(@NotNull WebSocketsChannelBindingBuilder webSocketsChannelBindingBuilder) {
this.method = webSocketsChannelBindingBuilder.method;
this.query = webSocketsChannelBindingBuilder.query;
this.headers = webSocketsChannelBindingBuilder.headers;
this.setBindingVersion("0.1.0");
this.extensionFields = webSocketsChannelBindingBuilder.extensionFields;
}

/**
* The HTTP method to use when establishing the connection.
Expand Down Expand Up @@ -59,13 +73,62 @@ public class WebSocketsChannelBinding extends ChannelBinding {
@JsonPropertyDescription("A Schema object containing the definitions of the HTTP headers to use when establishing the connection. This schema MUST be of type object and have a properties key.")
private AsyncAPISchema headers;

/**
* The version of this binding. If omitted, "latest" <b>MUST</b> be assumed.
*/
@Nullable
@Builder.Default
@JsonProperty("bindingVersion")
@JsonPropertyDescription("The version of this binding.")
private String bindingVersion = "0.1.0";
@Override
public String getBindingVersion() {
return "0.1.0";
}

@Override
public void setBindingVersion(@Nullable String bindingVersion) {
super.setBindingVersion("0.1.0");
}

public static WebSocketsChannelBindingBuilder builder() {
return new WebSocketsChannelBindingBuilder();
}

public static class WebSocketsChannelBindingBuilder {

@Nullable
private WebSocketsChannelMethod method;

@Nullable
private AsyncAPISchema query;

@Nullable
private AsyncAPISchema headers;

@Nullable
private Map<String, Object> extensionFields;

@NotNull
public WebSocketsChannelBindingBuilder method(@Nullable WebSocketsChannelMethod method) {
this.method = method;
return this;
}

@NotNull
public WebSocketsChannelBindingBuilder query(@Nullable AsyncAPISchema query) {
this.query = query;
return this;
}

@NotNull
public WebSocketsChannelBindingBuilder headers(@Nullable AsyncAPISchema headers) {
this.headers = headers;
return this;
}

@NotNull
public WebSocketsChannelBindingBuilder extensionFields(@Nullable Map<String, Object> extensionFields) {
this.extensionFields = extensionFields;
return this;
}

public WebSocketsChannelBinding build() {
return new WebSocketsChannelBinding(this);
}

}

}
Loading

0 comments on commit d29ad69

Please sign in to comment.