Skip to content

Commit

Permalink
Merge branch 'master' into nunjucks
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg authored Oct 21, 2024
2 parents af8cff7 + 25c4e53 commit cc50175
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/generator/lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Generator {
Object.defineProperty(this.templateParams, key, {
enumerable: true,
get() {
if (!self.templateConfig.parameters || !self.templateConfig.parameters[key]) {
if (!self.templateConfig.parameters?.[key]) {
throw new Error(`Template parameter "${key}" has not been defined in the package.json file under generator property. Please make sure it's listed there before you use it in your template.`);
}
return templateParams[key];
Expand Down
2 changes: 1 addition & 1 deletion apps/generator/lib/templateConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function getParamSuggestion(wrongParam, configParams) {
* @param {Object} templateParams All parameters provided to generator
*/
function isProvidedParameterSupported(configParams, templateParams) {
const wrongParams = Object.keys(templateParams || {}).filter(key => !configParams || !configParams[key]);
const wrongParams = Object.keys(templateParams || {}).filter(key => !configParams?.[key]);

if (!wrongParams.length) return;
if (!configParams) throw new Error('This template doesn\'t have any params.');
Expand Down
4 changes: 2 additions & 2 deletions apps/generator/test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jest.mock('@asyncapi/generator-react-sdk');

describe('React renderer', () => {
describe('saveRenderedReactContent', () => {
let util = undefined;
let AsyncReactSDK = undefined;
let util;
let AsyncReactSDK;
beforeAll(() => {
util = require('../lib/utils');
AsyncReactSDK = require('@asyncapi/generator-react-sdk');
Expand Down
6 changes: 4 additions & 2 deletions apps/nunjucks-filters/src/customFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ function docline(field, fieldName, scopePropName) {
const getPName = (pName) => pName ? `${pName}.` : '';

const buildLineCore = (type, def, pName, fName) => {
return `* @param {${type}} ${pName}${fName}${def !== undefined ? `=${def}` : ''}`;
const paramName = `${pName}${fName}`;
const defaultValue = def !== undefined ? `=${def}` : '';
return `* @param {${type}} ${paramName}${defaultValue}`;
};

const buildLine = (f, fName, pName) => {
const type = getType(f);
const def = getDefault(f, type);
Expand Down

0 comments on commit cc50175

Please sign in to comment.