Skip to content

Commit

Permalink
Partially fix devongovett#11: Allows recursive types with one level o…
Browse files Browse the repository at this point in the history
…f recursion
  • Loading branch information
ilyanep committed Jun 9, 2020
1 parent 0ebe901 commit dfab5b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ Compiler.prototype.compileMessage = function(message, root) {
};

message.fields.forEach(function(field) {
if (field.map) {
if (field.type === message.name) {
res.properties[field.name] = { $ref: '#/definitions/' + message.id }
} else if (field.map) {
if (field.map.from !== 'string')
throw new Error('Can only use strings as map keys at ' + message.id + '.' + field.name);

Expand All @@ -181,6 +183,7 @@ Compiler.prototype.compileMessage = function(message, root) {
if (field.required)
res.required.push(field.name);
}, this);


if (res.required.length === 0)
delete res.required;
Expand Down

0 comments on commit dfab5b7

Please sign in to comment.