Skip to content

Commit

Permalink
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Browse files Browse the repository at this point in the history
…erencing a json schema

Include internal definitions from bindings to composed schema

#494
asyncapi/jasyncapi-idea-plugin#49
  • Loading branch information
Pakisan committed Mar 12, 2024
1 parent 78ce54d commit b5f2139
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
node_modules
.nyc_output
.vscode
coverage
coverage

.DS_Store
/test/.DS_Store
/examples/.DS_Store
/bindings/.DS_Store
/.git/.DS_Store
/definitions/.DS_Store
46 changes: 23 additions & 23 deletions schemas/3.0.0-without-$id.json
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@
"properties": {
"type": "array",
"items": {
"$ref": "#/definitions/bindings-jms-0.0.1-server"
"$ref": "#/definitions/bindings-jms-0.0.1-server/definitions/property"
},
"description": "Additional properties to set on the JMS ConnectionFactory implementation for the JMS Provider."
},
Expand Down Expand Up @@ -2702,7 +2702,7 @@
"description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string."
}
},
"allOf": [
"anyOf": [
{
"if": {
"not": {
Expand Down Expand Up @@ -5472,10 +5472,10 @@
"description": "The name of the topic. Can be different from the channel name to allow flexibility around AWS resource naming limitations."
},
"ordering": {
"$ref": "#/definitions/bindings-sns-0.1.0-channel"
"$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/ordering"
},
"policy": {
"$ref": "#/definitions/bindings-sns-0.1.0-channel"
"$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/policy"
},
"tags": {
"type": "object",
Expand Down Expand Up @@ -5530,7 +5530,7 @@
"type": "array",
"description": "An array of statement objects, each of which controls a permission for this topic",
"items": {
"$ref": "#/definitions/bindings-sns-0.1.0-channel"
"$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/statement"
}
}
},
Expand Down Expand Up @@ -5617,11 +5617,11 @@
"properties": {
"queue": {
"description": "A definition of the queue that will be used as the channel.",
"$ref": "#/definitions/bindings-sqs-0.2.0-channel"
"$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/queue"
},
"deadLetterQueue": {
"description": "A definition of the queue that will be used for un-processable messages.",
"$ref": "#/definitions/bindings-sqs-0.2.0-channel"
"$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/queue"
},
"bindingVersion": {
"type": "string",
Expand Down Expand Up @@ -5700,10 +5700,10 @@
"default": 345600
},
"redrivePolicy": {
"$ref": "#/definitions/bindings-sqs-0.2.0-channel"
"$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/redrivePolicy"
},
"policy": {
"$ref": "#/definitions/bindings-sqs-0.2.0-channel"
"$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/policy"
},
"tags": {
"type": "object",
Expand All @@ -5725,7 +5725,7 @@
},
"properties": {
"deadLetterQueue": {
"$ref": "#/definitions/bindings-sqs-0.2.0-channel"
"$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/identifier"
},
"maxReceiveCount": {
"type": "integer",
Expand Down Expand Up @@ -5769,7 +5769,7 @@
"type": "array",
"description": "An array of statement objects, each of which controls a permission for this queue.",
"items": {
"$ref": "#/definitions/bindings-sqs-0.2.0-channel"
"$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/statement"
}
}
},
Expand Down Expand Up @@ -7330,19 +7330,19 @@
},
"properties": {
"topic": {
"$ref": "#/definitions/bindings-sns-0.1.0-operation",
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier",
"description": "Often we can assume that the SNS Topic is the channel name-we provide this field in case the you need to supply the ARN, or the Topic name is not the channel name in the AsyncAPI document."
},
"consumers": {
"type": "array",
"description": "The protocols that listen to this topic and their endpoints.",
"items": {
"$ref": "#/definitions/bindings-sns-0.1.0-operation"
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/consumer"
},
"minItems": 1
},
"deliveryPolicy": {
"$ref": "#/definitions/bindings-sns-0.1.0-operation",
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/deliveryPolicy",
"description": "Policy for retries to HTTP. The field is the default for HTTP receivers of the SNS Topic which may be overridden by a specific consumer."
},
"bindingVersion": {
Expand Down Expand Up @@ -7410,7 +7410,7 @@
},
"endpoint": {
"description": "The endpoint messages are delivered to.",
"$ref": "#/definitions/bindings-sns-0.1.0-operation"
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier"
},
"filterPolicy": {
"type": "object",
Expand Down Expand Up @@ -7451,10 +7451,10 @@
"description": "If true AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If false the SNS attributes are included in the body."
},
"redrivePolicy": {
"$ref": "#/definitions/bindings-sns-0.1.0-operation"
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/redrivePolicy"
},
"deliveryPolicy": {
"$ref": "#/definitions/bindings-sns-0.1.0-operation",
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/deliveryPolicy",
"description": "Policy for retries to HTTP. The parameter is for that SNS Subscription and overrides any policy on the SNS Topic."
},
"displayName": {
Expand Down Expand Up @@ -7526,7 +7526,7 @@
},
"properties": {
"deadLetterQueue": {
"$ref": "#/definitions/bindings-sns-0.1.0-operation",
"$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier",
"description": "The SQS queue to use as a dead letter queue (DLQ)."
},
"maxReceiveCount": {
Expand Down Expand Up @@ -7604,7 +7604,7 @@
"type": "array",
"description": "Queue objects that are either the endpoint for an SNS Operation Binding Object, or the deadLetterQueue of the SQS Operation Binding Object.",
"items": {
"$ref": "#/definitions/bindings-sqs-0.2.0-operation"
"$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/queue"
}
},
"bindingVersion": {
Expand Down Expand Up @@ -7688,10 +7688,10 @@
"default": 345600
},
"redrivePolicy": {
"$ref": "#/definitions/bindings-sqs-0.2.0-operation"
"$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/redrivePolicy"
},
"policy": {
"$ref": "#/definitions/bindings-sqs-0.2.0-operation"
"$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/policy"
},
"tags": {
"type": "object",
Expand All @@ -7712,7 +7712,7 @@
},
"properties": {
"deadLetterQueue": {
"$ref": "#/definitions/bindings-sqs-0.2.0-operation"
"$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/identifier"
},
"maxReceiveCount": {
"type": "integer",
Expand Down Expand Up @@ -7756,7 +7756,7 @@
"type": "array",
"description": "An array of statement objects, each of which controls a permission for this queue.",
"items": {
"$ref": "#/definitions/bindings-sqs-0.2.0-operation"
"$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/statement"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion schemas/3.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@
"description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string."
}
},
"allOf": [
"anyOf": [
{
"if": {
"not": {
Expand Down
8 changes: 7 additions & 1 deletion tools/bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ function getDefinitionName(def) {
}
if (def.startsWith('http://asyncapi.com/bindings')) {
const result = bindingsRegex.exec(def);
if (result) return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}`;
if (result) {
if (result[4] === '') {
return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}`;
} else {

Check failure on line 171 in tools/bundler/index.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Unnecessary 'else' after 'return'
return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}/${result[4].replace('#/', '')}`;
}
}
}

return path.basename(def, '.json');
Expand Down

0 comments on commit b5f2139

Please sign in to comment.