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

refactor: Resolve different code issues in template filter #29

Merged
merged 1 commit into from
Oct 7, 2020
Merged
Changes from all commits
Commits
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
16 changes: 7 additions & 9 deletions filters/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ filter.identifierName = identifierName;
// For files like the streetlights tutorial that don't have schemas, this finds the first anonymous schema in a message payload.
function anonymousSchema(asyncapi) {
let ret = null;
for (channelName in asyncapi.channels()) {
for (const channelName in asyncapi.channels()) {
let channel = asyncapi.channel(channelName);
let sub = channel.subscribe();
//console.log("anonymousSchema " + channelName);
Expand Down Expand Up @@ -129,7 +129,6 @@ filter.server = server;

// This returns an object containing information the template needs to render topic strings.
function topicInfo([channelName, channel]) {
let p = channel.parameters();
return getTopicInfo(channelName, channel);
}
filter.topicInfo = topicInfo;
Expand Down Expand Up @@ -186,7 +185,6 @@ function determineType(name, property) {
let itemsType = items.type();

if (itemsType) {

if (itemsType === 'object') {
ret.recursive = true;
itemsType = _.upperFirst(ret.pythonName);
Expand All @@ -195,6 +193,7 @@ function determineType(name, property) {
itemsType = typeMap[itemsType];
}
}

if (!itemsType) {
itemsType = items.ext('x-parser-schema-id');
ret.referenceType = itemsType;
Expand Down Expand Up @@ -303,10 +302,9 @@ function getFunctionNameByChannel(channelName, channel) {
}

function getMessengers([params, asyncapi]) {
let haveMessenger = false;
let ret = [];

for (channelName in asyncapi.channels()) {
for (const channelName in asyncapi.channels()) {
let channel = asyncapi.channel(channelName);
let sub = templateUtil.getRealSubscriber(asyncapi.info(), params, channel);

Expand Down Expand Up @@ -338,7 +336,7 @@ filter.getMessengers = getMessengers;
function getFirstPublisherMessenger([params, asyncapi]) {
//console.log('getFirstPublisherMessenger');
let ret = null;
for (channelName in asyncapi.channels()) {
for (const channelName in asyncapi.channels()) {
let channel = asyncapi.channel(channelName);
let pub = templateUtil.getRealPublisher(asyncapi.info(), params, channel);

Expand Down Expand Up @@ -374,9 +372,9 @@ function getTopicInfo(channelName, channel) {
//console.log("params: " + JSON.stringify(channel.parameters()));
for (let name in channel.parameters()) {
const nameWithBrackets = "{" + name + "}";
const parameter = channel.parameter(name);
const schema = parameter.schema();
const type = schema.type();
//const parameter = channel.parameter(name);
//const schema = parameter.schema();
//const type = schema.type();
const param = { "name": _.lowerFirst(name) };
//console.log("name: " + name + " type: " + type);
let sampleArg = 1;
Expand Down