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

Festure/28498-improve-openapi #693

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
83 changes: 71 additions & 12 deletions ext/hivemq-edge-openapi-2024.8-SNAPSHOT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4328,7 +4328,9 @@ components:
type: string
description: The adapter type associated with this instance
required:
- config
- id
- type
AdapterConfig:
type: object
properties:
Expand Down Expand Up @@ -4684,7 +4686,6 @@ components:
type: string
format: date-time
description: Time the data-point was generated
nullable: true
value:
type: integer
format: int64
Expand Down Expand Up @@ -4787,10 +4788,13 @@ components:
description:
type: string
description: A user created description for this tag.
maxLength: 10000
name:
type: string
format: mqtt-tag
description: The name of the tag that identifies it within this edge instance.
maxLength: 65535
minLength: 1
required:
- definition
- name
Expand Down Expand Up @@ -5068,9 +5072,15 @@ components:
type: string
description: The field in the output object where the data will be written
to
maxLength: 2048
minLength: 1
source:
type: string
description: The field in the input object where the data will be read from
maxLength: 2048
minLength: 1
transformation:
$ref: '#/components/schemas/Transformation'
required:
- destination
- source
Expand Down Expand Up @@ -5289,8 +5299,12 @@ components:
properties:
name:
type: string
description: Name of the associated property
title: Name
value:
type: string
description: Value of the associated property
title: Value
required:
- name
- value
Expand All @@ -5300,40 +5314,44 @@ components:
properties:
includeTagNames:
type: boolean
default: false
description: Should tag names be included when sent out.
includeTimestamp:
type: boolean
default: false
description: Should the timestamp be included when sent out.
maxQoS:
$ref: '#/components/schemas/QoS'
messageExpiryInterval:
type: integer
format: int64
default: 9007199254740991
description: The message expiry interval.
maximum: 9007199254740991
minimum: 0
messageHandlingOptions:
type: string
description: How collected tags should or shouldnÖT be aggregated.
enum:
- MQTTMessagePerTag
- MQTTMessagePerSubscription
tagName:
type: string
format: mqtt-tag
description: The tag for which values hould be collected and sent out.
maxLength: 2048
minLength: 1
topic:
type: string
format: ' mqtt-topic'
description: The target mqtt topic where received tags should be sent to.
maxLength: 65535
minLength: 1
userProperties:
type: array
description: User properties to be added to each outgoing mqtt message.
items:
$ref: '#/components/schemas/MqttUserProperty'
required:
- includeTagNames
- includeTimestamp
- maxQoS
- messageExpiryInterval
- messageHandlingOptions
- tagName
- topic
NorthboundMappingList:
Expand Down Expand Up @@ -5581,6 +5599,7 @@ components:
- items
QoS:
type: string
default: AT_LEAST_ONCE
description: The maximum MQTT-QoS for the outgoing messages.
enum:
- AT_MOST_ONCE
Expand Down Expand Up @@ -5693,9 +5712,13 @@ components:
type: string
format: mqtt-tag
description: The tag for which values hould be collected and sent out.
maxLength: 2048
minLength: 1
topicFilter:
type: string
description: The filter defining what topics we will receive messages from.
maxLength: 65535
minLength: 1
required:
- tagName
- topicFilter
Expand Down Expand Up @@ -5725,6 +5748,9 @@ components:
id:
type: string
description: The identifier of the object
maxLength: 500
minLength: 1
pattern: "^([a-zA-Z_0-9-_])*$"
lastActivity:
type: string
format: date-time
Expand All @@ -5745,6 +5771,12 @@ components:
type:
type: string
description: The type of the object
maxLength: 500
required:
- connection
- id
- runtime
- type
StatusList:
type: object
properties:
Expand All @@ -5765,6 +5797,8 @@ components:
- START
- STOP
- RESTART
required:
- command
StatusTransitionResult:
type: object
properties:
Expand All @@ -5778,6 +5812,9 @@ components:
identifier:
type: string
description: The identifier of the object in transition
maxLength: 500
minLength: 1
pattern: "^([a-zA-Z_0-9-_])*$"
status:
type: string
description: The status to perform on the target connection.
Expand All @@ -5787,6 +5824,12 @@ components:
type:
type: string
description: The type of the object in transition
maxLength: 500
required:
- callbackTimeoutMillis
- identifier
- status
- type
TagSchema:
type: object
properties:
Expand All @@ -5795,6 +5838,10 @@ components:
protocolId:
type: string
description: The id assigned to the protocol adapter type
maxLength: 100
required:
- configSchema
- protocolId
TlsConfiguration:
type: object
description: tlsConfiguration associated with the bridge
Expand Down Expand Up @@ -5853,17 +5900,21 @@ components:
description:
type: string
description: The name for this topic filter.
maxLength: 65535
filter:
type: string
format: mqtt-topic-filter
description: The topic filter according to the MQTT specification.
maxLength: 65535
minLength: 1
schema:
type: string
format: data-url
description: The optional json schema for this topic filter in the data
uri format.
topicFilter:
type: string
format: mqtt-topic-filter
description: The topic filter according to the MQTT specification.
nullable: true
required:
- topicFilter
- filter
TopicFilterList:
type: object
properties:
Expand All @@ -5874,6 +5925,9 @@ components:
$ref: '#/components/schemas/TopicFilter'
required:
- items
Transformation:
type: object
description: The kind of transformation that is performed on the data.
TypeIdentifier:
type: object
description: The unique id of the event object
Expand Down Expand Up @@ -5901,9 +5955,14 @@ components:
password:
type: string
description: The password associated with the user
maxLength: 1000
userName:
type: string
description: The userName associated with the user
maxLength: 1000
required:
- password
- userName
ValuesTree:
type: object
properties:
Expand Down
23 changes: 23 additions & 0 deletions hivemq-edge/src/main/java/com/hivemq/api/format/DataUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
public class DataUrl {

public static final String BASE64_TOKEN = ";base64";
public static final String DATA_TOKEN = "data:";


private final @NotNull String mimeType;
private final @NotNull String encoding;
Expand All @@ -51,9 +53,11 @@ public class DataUrl {


public static @NotNull DataUrl create(final @NotNull String dataUrlAsString) {
checkDataPrefix(dataUrlAsString);
// remove data:
final String dataUrlWithoutDataPrefix = dataUrlAsString.substring(5);
// split meta data and data on the ','
checkSeparator(dataUrlWithoutDataPrefix, dataUrlAsString);
final String[] metaDataAndDataSplit = dataUrlWithoutDataPrefix.split(",");
if (metaDataAndDataSplit.length != 2) {
throw new IllegalArgumentException(dataUrlAsString +
Expand All @@ -75,6 +79,25 @@ public class DataUrl {
}
}

private static void checkDataPrefix(final @NotNull String dataUrlAsString) {
if (!dataUrlAsString.startsWith(DATA_TOKEN)) {
throw new IllegalArgumentException("The supplied String '" +
dataUrlAsString +
"' does not start with the required prefix '" +
DATA_TOKEN +
"'.");
}
}

private static void checkSeparator(
final @NotNull String dataUrlWithoutDataPrefix, final @NotNull String dataUrlAsString) {
if (!dataUrlWithoutDataPrefix.contains(",")) {
throw new IllegalArgumentException("The supplied String '" +
dataUrlAsString +
"' does not contain the necessary ',' as separator between metadata and data.");
}
}


public @NotNull String getCharset() {
return charset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@

public class Adapter {

@JsonProperty("id")
@JsonProperty(value = "id", required = true)
@Schema(name = "id",
description = "The adapter id, must be unique and only contain alpha numeric characters with spaces and hyphens.",
format = "string",
minLength = 1,
required = true,
requiredMode = Schema.RequiredMode.REQUIRED,
maxLength = HiveMQEdgeConstants.MAX_ID_LEN,
pattern = HiveMQEdgeConstants.ID_REGEX)
private final @NotNull String id;

@JsonProperty("type")
@JsonProperty(value = "type", required = true)
@Schema(name = "type",
requiredMode = Schema.RequiredMode.REQUIRED,
description = "The adapter type associated with this instance")
private final @NotNull String protocolAdapterType;

@JsonProperty("config")
@JsonProperty(value = "config", required = true)
@Schema(name = "config",
requiredMode = Schema.RequiredMode.REQUIRED,
description = "The adapter configuration associated with this instance")
private final @NotNull JsonNode config;

Expand All @@ -53,9 +55,9 @@ public class Adapter {

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Adapter(
@JsonProperty("id") final @NotNull String id,
@JsonProperty("type") final @NotNull String protocolAdapterType,
@JsonProperty("config") final @NotNull JsonNode config,
@JsonProperty(value = "id", required = true) final @NotNull String id,
@JsonProperty(value = "type", required = true) final @NotNull String protocolAdapterType,
@JsonProperty(value = "config", required = true) final @NotNull JsonNode config,
@JsonProperty("status") final @Nullable Status status) {
this.id = id;
this.protocolAdapterType = protocolAdapterType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,32 @@
*/
public class UsernamePasswordCredentials {

@JsonProperty("userName")
@Schema(description = "The userName associated with the user")
@JsonProperty(value = "userName", required = true)
@Schema(description = "The userName associated with the user",
requiredMode = Schema.RequiredMode.REQUIRED,
maxLength = 1000)
private final @NotNull String userName;

@JsonProperty("password")
@Schema(description = "The password associated with the user")
@JsonProperty(value = "password", required = true)
@Schema(description = "The password associated with the user",
requiredMode = Schema.RequiredMode.REQUIRED,
maxLength = 1000)
private final @NotNull String password;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public UsernamePasswordCredentials(
@JsonProperty("userName") final @NotNull String userName,
@JsonProperty("password") final @NotNull String password) {
@JsonProperty(value = "userName", required = true) final @NotNull String userName,
@JsonProperty(value = "password", required = true) final @NotNull String password) {

this.userName = userName;
this.password = password;
}

public String getUserName() {
public @NotNull String getUserName() {
return userName;
}

public String getPassword() {
public @NotNull String getPassword() {
return password;
}
}
Loading
Loading