{"id":13879151,"url":"https://github.com/wantedly/open_api_annotator","last_synced_at":"2025-03-16T19:30:52.480Z","repository":{"id":44637739,"uuid":"135032798","full_name":"wantedly/open_api_annotator","owner":"wantedly","description":"OpenAPI spec generation by bottom-up.","archived":false,"fork":false,"pushed_at":"2023-12-15T11:46:47.000Z","size":63,"stargazers_count":12,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T00:11:37.061Z","etag":null,"topics":["actionpack","activemodelserializers","oas3","openapi","rails"],"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/wantedly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-27T09:30:51.000Z","updated_at":"2024-11-25T15:18:56.000Z","dependencies_parsed_at":"2023-12-15T12:50:48.382Z","dependency_job_id":null,"html_url":"https://github.com/wantedly/open_api_annotator","commit_stats":null,"previous_names":["ngtk/open_api_annotator"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fopen_api_annotator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fopen_api_annotator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fopen_api_annotator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Fopen_api_annotator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wantedly","download_url":"https://codeload.github.com/wantedly/open_api_annotator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826780,"owners_count":20354220,"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":["actionpack","activemodelserializers","oas3","openapi","rails"],"created_at":"2024-08-06T08:02:11.406Z","updated_at":"2025-03-16T19:30:52.099Z","avatar_url":"https://github.com/wantedly.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# OpenApiAnnotator [![Gem Version](https://badge.fury.io/rb/open_api_annotator.svg)](https://badge.fury.io/rb/open_api_annotator) [![Build Status](https://travis-ci.org/wantedly/open_api_annotator.svg?branch=master)](https://travis-ci.org/wantedly/open_api_annotator) [![Maintainability](https://api.codeclimate.com/v1/badges/8be7a273496459c62190/maintainability)](https://codeclimate.com/github/wantedly/open_api_annotator/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/8be7a273496459c62190/test_coverage)](https://codeclimate.com/github/wantedly/open_api_annotator/test_coverage)\n\nOpenApiAnnotator realizes to generate OpenAPI spec by annotating to controllers and serializers.\nIf you use ActiveModelSerializer, this is the best way to generate OpenAPI spec.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'open_api_annotator'\n```\n\n## Usage\n\nAnnotating controllers and serializers, you can generate OpenAPI spec file from these.\nThings you have to do are three below:\n\n1. Configure API meta information\n1. Annotate controllers\n1. Annotate serializers\n\n### 1. Configure API meta information\nYou have to set API meta information like:\n\n```rb\n# config/initializers/open_api_annotator.rb\nOpenApiAnnotator.configure do |config|\n  config.info = OpenApi::Info.new(title: \"Book API\", version: \"1\")\n  config.destination_path = Rails.root.join(\"api_spec.yml\")\n  config.path_regexp = /\\Aapi\\/v1\\// # If you want to restrict a path to create\nend\n```\n\n\n### 2. Annotate controller\nTo define an entity of an endpoint, call the method `endpoint` in the previous line of an action method. It takes entity expression as the first arg. Entity expression is a model class or an array that contains only one model class.\n\n```rb\nclass Api::V1::BooksController\n  endpoint [Book] # 👈It means an array of Book\n  def index\n    books = Book.limit(10)\n    render json: books\n  end\n\n  endpoint Book # 👈Just a Book\n  def show\n    book = Book.find(params[:id])\n    render json: book\n  end\n\n  endpoint Book # 👈Just a Book\n  def update\n     book = Book.find(params[:id])\n     book.update!(book_params)\n     render json: book\n  end\nend\n```\n\n### 3. Annotate serializer\nTo define an schema in components, set `type`, `format`, `nullable` as each field option.\n\n```rb\nclass BookSerializer \u003c ApplicationSerializer\n  attribute :title, type: :string, nullable: false\n  attribute :published_at, type: :string, format: :\"date-time\", nullable: true\n\n  has_many :authors, type: [Author], nullable: false\n  has_one :cover_image, type: CoverImage, nullable: true\n  belongs_to :publisher, type: Publisher, nullable: false\nend\n```\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number using `bundle exec bump patch`(or minor, major), and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wantedly/open_api_annotator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the OpenApiAnnotator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wantedly/open_api_annotator/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwantedly%2Fopen_api_annotator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwantedly%2Fopen_api_annotator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwantedly%2Fopen_api_annotator/lists"}