gatsby-source-openapi-aggregate
gatsby-source-openapi-aggregate copied to clipboard
childOpenApiSpecResponse.childrenOpenApiSpecDefinition doesn't contain all referenced definitions
The current childrenOpenApiSpecDefinition contains the primary definition only. The definition may reference other definitions (recursively?) to build up the full tree of definitions. I have this working locally for my 1-level nesting using the code:
const definitionId = ref ? ref.replace('#/definitions/', '') : null;
let children = definitionId ? [`${rootId}.definition.${definitionId}`] : [];
if (definitionId) {
const mainDefinition = definitions.filter(definition => definition.fields.name === definitionId)[0];
const referencedDefinitions =
mainDefinition.fields.properties.
map(prop => prop.referencedDefinition).
filter((p) => p).
map(id => `${rootId}.definition.${id}`);
children = children.concat(Array.from(new Set(referencedDefinitions)));
}
return {
id: `${rootId}.path.${p}.verb.${v}.response.${r}`,
parent: `${rootId}.path.${p}.verb.${v}`,
children,
fields: {
statusCode: r,
description: response.description
}
};
Thank you for the report, work has started on another branch which is looking to deal with recursive definitions, I'm hoping to pick this up again early next week.