{"id":13879153,"url":"https://github.com/kevindew/openapi3_parser","last_synced_at":"2025-04-06T10:11:05.076Z","repository":{"id":26188967,"uuid":"107609542","full_name":"kevindew/openapi3_parser","owner":"kevindew","description":"Open API 3 Parser/Validator for Ruby","archived":false,"fork":false,"pushed_at":"2025-02-24T14:46:53.000Z","size":1226,"stargazers_count":100,"open_issues_count":2,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-30T09:05:44.608Z","etag":null,"topics":["openapi","openapi-specification","parser","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/kevindew.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-19T23:33:52.000Z","updated_at":"2025-03-13T18:41:47.000Z","dependencies_parsed_at":"2025-03-02T08:10:34.890Z","dependency_job_id":"6eb4dba4-5059-423b-bcff-35fa3975ee54","html_url":"https://github.com/kevindew/openapi3_parser","commit_stats":null,"previous_names":["kevindew/openapi_parser"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevindew%2Fopenapi3_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevindew%2Fopenapi3_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevindew%2Fopenapi3_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevindew%2Fopenapi3_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevindew","download_url":"https://codeload.github.com/kevindew/openapi3_parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464220,"owners_count":20942970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["openapi","openapi-specification","parser","ruby"],"created_at":"2024-08-06T08:02:11.484Z","updated_at":"2025-04-06T10:11:05.044Z","avatar_url":"https://github.com/kevindew.png","language":"Ruby","readme":"# OpenAPI 3 Parser\n\n![ci workflow](https://github.com/kevindew/openapi3_parser/actions/workflows/ci.yml/badge.svg)\n\nThis a Ruby based parser/validator for [OpenAPI 3][openapi-3]. It is used to\nconvert an OpenAPI file (can be a local file, a URL, a string or even a Ruby\nhash) into an object graph with a simple API that follows the [OpenAPI\nspecification][openapi-3-spec].\n\nBasic example:\n\n```ruby\nrequire \"openapi3_parser\"\n\ndocument = Openapi3Parser.load_url(\"https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml\")\n\ndocument.paths[\"/pets\"].get.summary\n# =\u003e \"List all pets\"\n```\n\nIt aims to support 100% of the OpenAPI 3.0 specification, with key features\nbeing:\n\n- Supports loading a specification by path to a file, URL, Ruby file objects,\n  and strings in YAML and JSON formats, it even supports loading via a Ruby hash;\n- Support for loading references from external files including URLs;\n- Handles recursive references;\n- All of OpenAPI specification mapped to Ruby objects, providing a natural\n  Ruby interface that maps clearly to the specification;\n- OpenAPI files validated with a simple API to quickly and simply see all\n  problems with a file\n- Built-in Markdown to HTML conversion;\n- Documentation for the API to navigate the OpenAPI nodes is available on\n  [rubydoc.info][docs].\n\nI've wrote a blog post reflecting on the decisions involved in building this\nparser in [How to write an OpenAPI 3 parser][blog].\n\n[openapi-3]: https://github.com/OAI/OpenAPI-Specification\n[openapi-3-spec]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#specification\n[docs]: http://www.rubydoc.info/github/kevindew/openapi3_parser/Openapi3Parser/Node/Openapi\n[blog]: https://kevindew.me/post/188611423231/how-to-write-an-openapi-3-parser\n\n## Usage\n\n### Loading a specification\n\n```ruby\n# by URL\nOpenapi3Parser.load_url(\"https://raw.githubusercontent.com/kevindew/openapi3_parser/main/spec/support/examples/petstore-expanded.yaml\")\n\n# by path to file\nOpenapi3Parser.load_file(\"spec/support/examples/uber.yaml\")\n\n# by File\nOpenapi3Parser.load(File.open(\"spec/support/examples/uber.yaml\"))\n\n# by String\nOpenapi3Parser.load('{ \"openapi\": \"3.0.0\", \"info\": { \"title\": \"API\", \"version\": \"1.0.0\" }, \"paths\": {}  }')\n\n# by Hash\nOpenapi3Parser.load(openapi: \"3.0.0\", info: { title: \"API\", version: \"1.0.0\" }, paths: {})\n\n```\n\n### Validating\n\n```ruby\ndocument = Openapi3Parser.load(openapi: \"3.0.0\", info: {}, paths: {})\ndocument.valid?\n# =\u003e false\ndocument.errors\n# =\u003e Openapi3Parser::Validation::ErrorCollection(errors: {\"#/info\"=\u003e[\"Missing required fields: title and version\"]})\n```\n\n### Traversing\n\n```ruby\ndocument = Openapi3Parser.load_url(\"https://raw.githubusercontent.com/kevindew/openapi3_parser/main/spec/support/examples/petstore-expanded.yaml\")\n\n# by objects\n\ndocument.info.terms_of_service\n# =\u003e \"http://swagger.io/terms/\"\n\ndocument.paths.keys\n# =\u003e [\"/pets\", \"/pets/{id}\"]\n\ndocument.paths[\"/pets\"].get.parameters.map(\u0026:name)\n# =\u003e [\"tags\", \"limit\"]\n\n# by hash syntax\n\ndocument[\"info\"][\"termsOfService\"]\n=\u003e \"http://swagger.io/terms/\"\n\ndocument[\"paths\"].keys\n# =\u003e [\"/pets\", \"/pets/{id}\"]\n\ndocument[\"paths\"][\"/pets\"][\"get\"][\"parameters\"].map(\u0026:name)\n# =\u003e [\"tags\", \"limit\"]\n\n# by a path to a node\ndocument.node_at(\"#/paths/%2Fpets/get/operationId\")\n=\u003e \"findPets\"\n\ndocument.node_at(\"#/components/schemas/Pet/allOf/0/required/0\")\n=\u003e \"name\"\n\n# or combining\n\ndocument.components.schemas[\"Pet\"].node_at(\"#../NewPet\")\n=\u003e Openapi3Parser::Node::Schema(#/components/schemas/NewPet)\n```\n\nYou can learn more about the API on [rubydoc.info][docs]\n\n## Installation\n\nYou can install this gem into your bundler application by adding this line to\nyour Gemfile:\n\n```\ngem \"openapi3_parser\", \"~\u003e 0.10.0\"\n```\n\nand then running `$ bundle install`\n\nOr install the gem onto your machine via `$ gem install openapi3_parser`\n\n## Status\n\nThis is currently a work in progress and will remain so until it reaches 1.0.\n\nSee [TODO](TODO.md) for details of the features still to implement.\n\n## Licence\n\n[MIT License](LICENCE)\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevindew%2Fopenapi3_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevindew%2Fopenapi3_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevindew%2Fopenapi3_parser/lists"}