Skip to content

Commit

Permalink
fix: definition object defintions based on proplist structure
Browse files Browse the repository at this point in the history
  • Loading branch information
alainlecluse committed Jun 9, 2020
1 parent 1b27fff commit 2fb9fc5
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions lib/markdownBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,31 +779,29 @@ function build({
* Generates the definitions section for a schema
* @param {*} schema
*/
function makedefinitions(schema, slugger) {
function makedefinitions(schema) {
if (schema.definitions || schema[keyword`$defs`]) {
const defgroups = [
...Object.entries(schema[keyword`$defs`] || {}),
...Object.entries(schema.definitions || {})]
.map(([groupname, subschema]) => {
const grouptable = makeproptable(
subschema[keyword`properties`],
subschema[keyword`patternProperties`],
subschema[keyword`additionalProperties`],
subschema[keyword`required`],
slugger,
);
const description = subschema[s.meta] && subschema[s.meta].longdescription ? subschema[s.meta].longdescription : paragraph(text(i18n`no description`));

return [
heading(2, text(i18n`Definitions group ${groupname}`)),
paragraph(text(i18n`Reference this group by using`)),
code('json', JSON.stringify({ $ref: `${subschema[s.id]}#${subschema[s.pointer]}` })),
grouptable,
...makeproplist(
subschema[keyword`properties`],
subschema[keyword`patternProperties`],
subschema[keyword`additionalProperties`],
subschema[keyword`required`],
2,
),
...[
description,
...makecomment(subschema),
paragraph(inlineCode(groupname)),
makefactlist(groupname, subschema),
...maketypesection(subschema, 2),
...makeconstraintssection(subschema, 2),
...makedefault(subschema, 2),
...makeexamples(subschema, 2),
...makerestrictions(subschema, 2),
],
];
});

Expand Down Expand Up @@ -854,7 +852,7 @@ function build({
...makedefault(schema, 1),
...makeexamples(schema, 1),
...makeproperties(schema, slugger),
...makedefinitions(schema, slugger),
...makedefinitions(schema),
]);
return pv;
});
Expand Down

0 comments on commit 2fb9fc5

Please sign in to comment.