Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@asyncapi/java-spring-cloud-stream-template

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asyncapi/java-spring-cloud-stream-template - npm Package Compare versions

Comparing version
0.11.7
to
0.12.0
+66
test/mocks/avro-schema-namespace.yaml
---
components:
schemas: {}
messages:
JobOrder:
payload:
name: "JobOrder"
namespace: "com.example.api.jobOrder"
doc: "JobOrder"
type: "record"
fields:
- name: "jobOrderId"
doc: "JobOrderID"
type: "string"
- name: "jobOrderDescription"
doc: "JobOrderDescription"
type: "string"
- name: "jobOrderLongDescription"
doc: "JobOrderLongDescription"
type: "string"
- name: "jobOrderNumber"
doc: "JobOrderNumber"
type: "string"
- name: "isActive"
doc: "IsActive"
type: "boolean"
- name: "status"
doc: "Status"
type: "string"
- name: "statuscode"
doc: "StatusCode"
type: "int"
schemaFormat: "application/vnd.apache.avro+json;version=1.9.0"
contentType: "application/vnd.apache.avro+json"
JobAck:
payload:
name: "JobAcknowledge"
namespace: "com.example.api.jobAck"
doc: "JobAck"
type: "record"
fields:
- name: "jobAckId"
doc: "JobAckID"
type: "string"
schemaFormat: "application/vnd.apache.avro+json;version=1.9.0"
contentType: "application/vnd.apache.avro+json"
servers:
production:
protocol: "kafka"
url: "pkc-ymrq7.us-east-2.aws.confluent.cloud:9092"
channels:
test.jobs.order:
subscribe:
message:
$ref: "#/components/messages/JobOrder"
test.jobs.ack:
publish:
message:
$ref: "#/components/messages/JobAck"
asyncapi: "2.0.0"
info:
x-generated-time: "2022-02-24 01:18 UTC"
description: ""
title: "Job Events"
x-view: "provider"
version: "1"
+1
-1

@@ -7,3 +7,3 @@ env:

parserOptions:
ecmaVersion: 2018
ecmaVersion: 2020

@@ -10,0 +10,0 @@ plugins:

@@ -1,2 +0,2 @@

#This action is centrally managed in https://github.com/asyncapi/.github/
#This action is centrally managed in https://github.com/asyncapi/.github/
#Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

@@ -7,3 +7,2 @@

on:
pull_request_target:

@@ -13,7 +12,8 @@ types: [opened, reopened, synchronize, edited, ready_for_review]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v3.2.5
lint:
runs-on: ubuntu-latest
steps:
# Since this workflow is REQUIRED for a PR to be mergable, we have to have this 'if' statement in step level instead of job level.
- if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }}
uses: amannn/action-semantic-pull-request@v3.2.5
env:

@@ -20,0 +20,0 @@ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

@@ -29,2 +29,3 @@ #This action is centrally managed in https://github.com/asyncapi/.github/

test:
if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }}
name: Checking sentiments

@@ -31,0 +32,0 @@ runs-on: ubuntu-latest

@@ -16,2 +16,3 @@ #This action is centrally managed in https://github.com/asyncapi/.github/

welcome:
if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }}
runs-on: ubuntu-latest

@@ -18,0 +19,0 @@ steps:

@@ -542,2 +542,46 @@ const filter = module.exports;

function extraImports([asyncapi, params]) {
return getExtraImports(asyncapi);
}
filter.extraImports = extraImports;
function getExtraImports(asyncapi) {
const schemaImports = [];
const channelOperationInfos = [];
for (const channelName in asyncapi.channels()) {
const channel = asyncapi.channels()[channelName];
if (channel.hasPublish()) {
channelOperationInfos.push(channel.publish());
}
if (channel.hasSubscribe()) {
channelOperationInfos.push(channel.subscribe());
}
}
if (channelOperationInfos.length > 0) {
channelOperationInfos.forEach(channelOperationInfo => {
const fullPackagePath = getPayloadPackage(channelOperationInfo);
if (fullPackagePath) {
schemaImports.push(fullPackagePath);
}
});
}
return schemaImports;
}
function getPayloadPackage(pubOrSub) {
let fullPackagePath;
if (!pubOrSub.hasMultipleMessages()) {
const payload = pubOrSub.message()?.payload();
if (payload) {
const type = payload.type();
const importName = payload.ext('x-parser-schema-id');
// This is a schema within a package - like an avro schema in a namespace. We're hoping the full thing is part of the x-schema-parser-id.
if ((!type || type === 'object') && importName.includes('.')) {
fullPackagePath = importName;
}
}
}
return fullPackagePath;
}
// Returns true if any property names will be different between json and java.

@@ -900,3 +944,4 @@ function checkPropertyNames(name, schema) {

ret = payload.ext('x-parser-schema-id');
ret = _.camelCase(ret);
const { className } = scsLib.stripPackageName(ret);
ret = _.camelCase(className);
ret = _.upperFirst(ret);

@@ -903,0 +948,0 @@ } else {

const ModelClass = require('./modelClass.js');
const debugApplicationModel = require('debug')('applicationModel');
const _ = require('lodash');
const ScsLib = require('./scsLib.js');
const scsLib = new ScsLib();
const instanceMap = new Map();

@@ -159,3 +161,3 @@

const { className, javaPackage } = this.stripPackageName(schemaName);
const { className, javaPackage } = scsLib.stripPackageName(schemaName);
modelClass.setJavaPackage(javaPackage);

@@ -190,11 +192,2 @@ modelClass.setClassName(className);

stripPackageName(schemaName) {
// If there is a dot in the schema name, it's probably an Avro schema with a fully qualified name (including the namespace.)
const indexOfDot = schemaName.lastIndexOf('.');
if (indexOfDot > 0) {
return { className: schemaName.substring(indexOfDot + 1), javaPackage: schemaName.substring(0, indexOfDot) };
}
return { className: schemaName, javaPackage: undefined };
}
reset() {

@@ -201,0 +194,0 @@ instanceMap.forEach((val) => {

@@ -88,2 +88,17 @@ // This contains functions that are common to both the all.js filter and the post-process.js hook.

/**
* Takes a string, splits on the last instance of '.' (dot) if it exists and returns an object of the separated pieces.
*
* @param {String} dotSeparatedName Example: 'com.solace.api.Schema'.
* @returns {Object} { javaPackage, className } Example: { javaPackage: "com.solace.api", className: "Schema" }.
*/
stripPackageName(dotSeparatedName) {
// If there is a dot in the schema name, it's probably an Avro schema with a fully qualified name (including the namespace.)
const indexOfDot = dotSeparatedName.lastIndexOf('.');
if (indexOfDot > 0) {
return { javaPackage: dotSeparatedName.substring(0, indexOfDot), className: dotSeparatedName.substring(indexOfDot + 1) };
}
return { className: dotSeparatedName };
}
initReservedWords() {

@@ -90,0 +105,0 @@ // This is the set of Java reserved words, to ensure that we don't generate any by mistake.

{
"name": "@asyncapi/java-spring-cloud-stream-template",
"version": "0.11.7",
"version": "0.12.0",
"description": "Java Spring Cloud Stream template for AsyncAPI generator.",

@@ -32,5 +32,5 @@ "scripts": {

"@asyncapi/generator-filters": "^2.1.0",
"@types/node": "^16.7.1",
"js-yaml": "^3.13.1",
"lodash": "^4.17.15",
"@types/node": "^16.7.1"
"lodash": "^4.17.15"
},

@@ -44,3 +44,3 @@ "devDependencies": {

"conventional-changelog-conventionalcommits": "^4.6.0",
"eslint": "^6.8.0",
"eslint": "^7.32.0",
"eslint-plugin-jest": "^24.3.6",

@@ -47,0 +47,0 @@ "jest": "^27.0.4",

{%- include 'partials/java-package' -%}
{%- set extraIncludes = [asyncapi, params] | appExtraIncludes %}
{%- set funcs = [asyncapi, params] | functionSpecs %}
{%- set imports = [asyncapi, params] | extraImports %}
{%- if extraIncludes.needFunction %}
import java.util.function.Function;
{%- endif %}
{%- endif -%}
{%- if extraIncludes.needConsumer %}
import java.util.function.Consumer;
{%- endif %}
{%- endif -%}
{%- if extraIncludes.needSupplier %}

@@ -40,2 +42,5 @@ import java.util.function.Supplier;

{%- endif %}
{%- for extraImport in imports %}
import {{ extraImport }};
{%- endfor %}
{% set className = [asyncapi.info(), params] | mainClassName %}

@@ -55,3 +60,2 @@ @SpringBootApplication

}
{% set funcs = [asyncapi, params] | functionSpecs -%}
{% for funcName, funcSpec in funcs %}

@@ -58,0 +62,0 @@ {%- if funcSpec.type === 'function' %}

@@ -175,2 +175,13 @@ const path = require('path');

});
it('should package and import schemas in another avro namespace', async () => {
await generate('mocks/avro-schema-namespace.yaml');
const validatedFiles = [
'src/main/java/Application.java',
'src/main/java/com/example/api/jobOrder/JobOrder.java',
'src/main/java/com/example/api/jobAck/JobAcknowledge.java'
];
await assertExpectedFiles(validatedFiles);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet