mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2026-01-14 02:58:29 +00:00
GitLab Grape OpenAPI
Warning
This gem is currently designed entirely for internal use at GitLab. This gem is not functional and not used in production.
Internal gem for generating OpenAPI 3.0 specifications from Grape API definitions.
Usage with gitlab-org/gitlab
-
With a running and configured GDK, start a
rails consolein a terminal. -
Use the script below to run the generator with all APIs and entities in the monolith.
Rails.application.eager_load! api_classes = API::Base.descendants entity_classes = Grape::Entity.descendants spec = Gitlab::GrapeOpenapi.generate(api_classes: api_classes, entity_classes: entity_classes) File.write(Rails.root.join('tmp', 'myfile.json'), JSON.pretty_generate(spec)) -
The OpenAPI 3.0 spec will be dumped in
tmp/myfile.jsonin theGDK_ROOT/gitlabdirectory. -
Ensure
redocly-cliis installed.npm install @redocly/cli -g -
To render the documentation in something viewable online, such as redocly, run
redocly build-docs ~/gdk/gitlab/tmp/myfile.jsonand open the generated static site.
Development
bundle install
bundle exec rspec