{"id":13452303,"url":"https://github.com/devdigital/gatsby-source-openapi-aggregate","last_synced_at":"2026-01-17T00:35:35.688Z","repository":{"id":42342795,"uuid":"108407334","full_name":"devdigital/gatsby-source-openapi-aggregate","owner":"devdigital","description":"Gatsby source plugin for pulling data into Gatsby from Open API/Swagger specifications","archived":false,"fork":false,"pushed_at":"2023-01-11T18:31:25.000Z","size":2673,"stargazers_count":27,"open_issues_count":44,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T19:40:34.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devdigital.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-26T12:17:27.000Z","updated_at":"2021-12-13T19:26:42.000Z","dependencies_parsed_at":"2023-02-09T04:17:04.087Z","dependency_job_id":null,"html_url":"https://github.com/devdigital/gatsby-source-openapi-aggregate","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/devdigital/gatsby-source-openapi-aggregate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdigital%2Fgatsby-source-openapi-aggregate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdigital%2Fgatsby-source-openapi-aggregate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdigital%2Fgatsby-source-openapi-aggregate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdigital%2Fgatsby-source-openapi-aggregate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devdigital","download_url":"https://codeload.github.com/devdigital/gatsby-source-openapi-aggregate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdigital%2Fgatsby-source-openapi-aggregate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28490259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T23:55:29.509Z","status":"ssl_error","status_checked_at":"2026-01-16T23:55:29.108Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T07:01:20.009Z","updated_at":"2026-01-17T00:35:35.671Z","avatar_url":"https://github.com/devdigital.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"Gatsby source plugin for pulling data into Gatsby from Open API/Swagger specifications\n\n- [Sample](/sample)\n\n## Features\n\n- Pulls Open API/Swagger JSON specifications from various sources, these can be local files or from HTTP services or any custom function which resolves a JSON spec\n- Supports multiple specs, so useful for aggregating numerous services where the specs are co-located with each service\n- Document your APIs using React!\n\n## What's missing\n\nThis is work in progress, currently:\n\n- No support for YAML\n- Only supports Swagger version 2.0 JSON\n- Various Swagger properties are not converted to fields on nodes, only the main properties (general information, paths, responses, and definitions), create an issue or PR\n\n## Install\n\n`npm install gatsby-source-openapi-aggregate --save`\n\n## Configuring plugin\n\n```javascript\n// gatsby-config.js\n\nplugins: [\n  {\n    resolve: `gatsby-source-openapi-aggregate`,\n    options: {\n      specs: [                // specs collection is required, you can define as many specs as you want\n        {\n          name: 'myspec',     // required, must be unique\n          resolve: () =\u003e ...  // required, function which returns a Promise resolving Swagger JSON\n        }\n      ]\n    }\n  }\n]\n```\n\n### Example resolve functions\n\nRetrieving Swagger document from local file:\n\n```javascript\nconst fs = require('fs')\nconst path = require('path')\n\nconst fromJson = filePath =\u003e {\n  return new Promise((resolve, reject) =\u003e {\n    fs.readFile(filePath, 'utf8', (err, data) =\u003e {\n      if (err) {\n        reject(err)\n        return\n      }\n\n      resolve(data)\n    })\n  })\n}\n\n...\n\n  plugins: [\n    {\n      resolve: `gatsby-source-openapi-aggregate`,\n      options: {\n        specs: [\n          {\n            name: 'myspec',\n            resolve: () =\u003e fromJson(path.resolve(__dirname, './swagger.json'))\n          }\n        ]\n      }\n    },\n\n```\n\nRetrieving Swagger document from HTTP request:\n\n```javascript\nconst fetchSpec = async url =\u003e {\n  return fetch(url).then(response =\u003e {\n    if (response.status === 200) {\n      return response.text()\n    }\n\n    throw new Error('There was an error retrieving document.')\n  })\n}\n```\n\n## How to query\n\nThe plugin adds the following collections:\n\n- `allOpenApiSpec`\n- `allOpenApiSpecPath`\n- `allOpenApiSpecResponse`\n- `allOpenApiSpecDefinition`\n\nYou can inspect these in GraphiQL at `http://localhost:8000/___graphql`\n\nFor example, to retrieve a list of spec names and titles ready for display:\n\n```javascript\n// src/pages/index.js\n\nexport const query = graphql`\n  query IndexQuery {\n    allOpenApiSpec {\n      edges {\n        node {\n          name\n          title\n        }\n      }\n    }\n    ...\n```\n\nTo create a detail page for each spec:\n\n```javascript\n// gatsby-node.js\n\nexports.createPages = ({ graphql, boundActionCreators }) =\u003e {\n  const { createPage } = boundActionCreators\n  return new Promise((resolve, reject) =\u003e {\n    graphql(`\n      {\n        allOpenApiSpec {\n          edges {\n            node {\n              id\n              name\n            }\n          }\n        }\n      }\n    `).then(result =\u003e {\n      result.data.allOpenApiSpec.edges.map(({ node }) =\u003e {\n        createPage({\n          path: `apis/${node.name}`,\n          component: path.resolve(`./src/templates/api.js`),\n          context: {\n            id: node.id,\n          },\n        })\n      })\n\n      resolve()\n    })\n  })\n}\n```\n\nThe above creates a new page for every spec defined in the plugin options, using `/apis/\u003cname\u003e` as the path, where `\u003cname\u003e` is the name you defined within the plugin options.\n\nEach page uses the `./src/templates/api.js` React component to render the detail page. The `node.id` is passed to the context so that it is available as a GraphQL variable so that we can retreive the appropriate spec node from the `api.js` component.\n\n```javascript\n// api.js\n\nexport const query = graphql`\n  query ApiQuery($id: String!) {\n    openApiSpec(id: { eq: $id }) {\n      version\n      title\n      description\n      childrenOpenApiSpecPath {\n        name\n        verb\n        summary\n        description\n        parameters {\n          name\n          in\n          description\n          required\n          type\n          format\n        }\n        tag\n        childrenOpenApiSpecResponse {\n          id\n          statusCode\n          description\n          childrenOpenApiSpecDefinition {\n            name\n            properties {\n              name\n              type\n              description\n              format\n            }\n          }\n        }\n      }\n    }\n  }\n`\n```\n\nIn the above example, we're using the `$id` variable to retrieve the appropriate spec for that page. We're retreiving basic spec information (such as `version`, `title`, `description`) as well as the children paths for the spec, their associated properties, as well as each paths child responses and in turn their child definitions.\n\nEach path has a `tags` and `tag` field - `tags` is the original array of tags associated with the path. The `tag` field is a convenience comma separated string of all tags. If you wish to display paths by tag (like Swagger UI), then you can group on this `tag` field. See the full [sample](/sample) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevdigital%2Fgatsby-source-openapi-aggregate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevdigital%2Fgatsby-source-openapi-aggregate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevdigital%2Fgatsby-source-openapi-aggregate/lists"}