gatsby-source-openapi-aggregate icon indicating copy to clipboard operation
gatsby-source-openapi-aggregate copied to clipboard

childOpenApiSpecResponse.childrenOpenApiSpecDefinition doesn't contain all referenced definitions

Open sb8244 opened this issue 7 years ago • 1 comments

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
          }
        };

sb8244 avatar Jun 24 '18 01:06 sb8244

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.

devdigital avatar Jun 28 '18 16:06 devdigital