Giter VIP home page Giter VIP logo

zero-rails_openapi's People

Contributors

am17torres avatar austbot avatar bopm avatar drjonnicholson avatar hikari-desu avatar rjayroach avatar schneems avatar ygrene-austin avatar zhandao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zero-rails_openapi's Issues

'block in load_missing_constant': uninitialized constant OpenApi

Hi,

I'm trying use your gem but when I copy 1:1 some basic example from readme then I got an error:

/app/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:76:in `block in load_missing_constant': uninitialized constant OpenApi (NameError)

The problem is appearing when I try run a server: rails s with configuration file:

config/initializers/open_api.rb

require 'open_api'

OpenApi::Config.class_eval do
  # Part 1: configs of this gem
  self.file_output_path = 'public/open_api'

  # Part 2: config (DSL) for generating OpenApi info
  open_api :doc_name, base_doc_classes: [ApiDoc]
  info version: '1.0.0', title: 'Homepage APIs'#, description: ..
  # server 'http://localhost:3000', desc: 'Internal staging server for testing'
  # bearer_auth :Authorization
end

I will appreciate for help.

comparison of Hash with Hash failed

When I add a second item to base_doc_classes. I get the following error.

/usr/local/bundle/gems/zero-rails_openapi-2.1.2/lib/open_api.rb:45:in `sort': comparison of Hash with Hash failed (ArgumentError)

This code triggers the error.
open_api :schema, base_doc_classes: [ApplicationController, Base]
If I comment out either item the error is removed.

$ bundle list 
root@b54e90fc0e0f:/var/app/current# bundle list
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Gems included by the bundle:
  * actioncable (6.0.2.1)
  * actionmailbox (6.0.2.1)
  * actionmailer (6.0.2.1)
  * actionpack (6.0.2.1)
  * actiontext (6.0.2.1)
  * actionview (6.0.2.1)
  * activejob (6.0.2.1)
  * activemodel (6.0.2.1)
  * activerecord (6.0.2.1)
  * activestorage (6.0.2.1)
  * activesupport (6.0.2.1)
  * bootsnap (1.4.5)
  * builder (3.2.4)
  * byebug (11.0.1)
  * colorize (0.8.1)
  * concurrent-ruby (1.1.5)
  * crass (1.0.5)
  * erubi (1.9.0)
  * ethon (0.12.0)
  * faraday (0.17.3)
  * faraday_middleware (0.13.1)
  * faraday_middleware-multi_json (0.0.6)
  * ffi (1.11.3)
  * globalid (0.4.2)
  * httpclient (2.8.3)
  * i18n (1.7.0)
  * json (2.3.0)
  * listen (3.1.5)
  * loofah (2.4.0)
  * mail (2.7.1)
  * marcel (0.3.3)
  * method_source (0.9.2)
  * mimemagic (0.3.3)
  * mini_mime (1.0.2)
  * mini_portile2 (2.4.0)
  * minitest (5.13.0)
  * msgpack (1.3.1)
  * multi_json (1.14.1)
  * multipart-post (2.1.1)
  * neo4j (9.6.1)
  * neo4j-core (9.0.0)
  * net_tcp_client (2.2.0)
  * nio4r (2.5.2)
  * nokogiri (1.10.7)
  * orm_adapter (0.5.0)
  * puma (4.3.1)
  * rack (2.0.8)
  * rack-cors (1.1.1)
  * rack-test (1.1.0)
  * rails (6.0.2.1)
  * rails-dom-testing (2.0.3)
  * rails-html-sanitizer (1.3.0)
  * railties (6.0.2.1)
  * rake (13.0.1)
  * rb-fsevent (0.10.3)
  * rb-inotify (0.10.1)
  * ruby_dep (1.5.0)
  * spring (2.1.0)
  * spring-watcher-listen (2.0.1)
  * sprockets (4.0.0)
  * sprockets-rails (3.2.1)
  * thor (1.0.1)
  * thread_safe (0.3.6)
  * typhoeus (1.3.1)
  * tzinfo (1.2.6)
  * websocket-driver (0.7.1)
  * websocket-extensions (0.1.4)
  * zeitwerk (2.2.2)
  * zero-rails_openapi (2.1.2)

What do you need next

I'm afraid I cant read everything on your backup log issue.
What improvements do you want on this gem. I use OAS heavily and am now leading a ruby micro services team so supporting this gem is in the best interest of me and my team.

additional_properties: true not generating correct doc

I have next definition:

schema FreeFormObj: {
  type: Object,
  additional_properties: true
}

I wait it to generate next valid doc:

"FreeFormObj": {
  "type": "object",
  "additionalProperties": true
}

but instead, it generates invalid one:

"FreeFormObj": {
  "type": "object",
  "additionalProperties": {
    "type": "true"
  }
}

Looking for a Rails 4 example!

I've found a lot of not great Swagger/Rails gems, so excited that this is OAS 3.0 compliant!

I followed the install step and am getting:

14:20:55 web.1    | [7] ! Unable to load application: NameError: uninitialized constant ApiDoc
14:20:55 worker.1 | uninitialized constant ApiDoc
14:20:55 worker.1 | /srv/app/config/initializers/01_open_api.rb:9:in `block in <top (required)>'

This is following this step: https://github.com/zhandao/zero-rails_openapi#configure

Response headers

Hi again @zhandao .

I'm trying to add paging related headers to responses. I've looked at https://github.com/zhandao/zero-rails_openapi/blob/master/lib/open_api/dsl/api.rb#L98, and see additional options can be passed. But the way these are handled force the additional hash into the content (https://github.com/zhandao/zero-rails_openapi/blob/master/lib/oas_objs/response_obj.rb#L20).

Would it be possible to add support for headers, or let me know of a work around please? Thanks!

Provide a more detailed dummy controller example

Sorry, but I can't figure out from the provided in README content what exactly should be added to a simple controller action so that it to be documented.

  • created the initializer:
#config/initializers/open_api.rb
require 'open_api'

OpenApi::Config.class_eval do
  # Part 1: configs of this gem
  self.file_output_path = 'public/open_api'

  # Part 2: config (DSL) for generating OpenApi info
  open_api :swagger, base_doc_classes: []
  info version: '1.0.0', title: 'Homepage APIs'#, description: ..
  # server 'http://localhost:3000', desc: 'Internal staging server for testing'
  # bearer_auth :Authorization
end
  • I added the following to a scaffolded PostsController:
#controllers/posts_controller.rb
class PostsController < ApplicationController
  before_action :set_post, only: [:show, :update, :destroy]
  
  api :index, 'GET list of posts' do
    query :page, Integer#, range: { ge: 1 }, default: 1
    query :rows, Integer#, desc: 'per page', range: { ge: 1 }, default: 10
  end

  # GET /posts
  def index
    @posts = Post.all

    render jsonapi: @posts
  end
...
end

But after generating the docs the way described below, the JSN file has nothing except:

#public/open_api/swagger.json
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Homepage APIs",
    "description": ""
  },
  "security": null,
  "tags": [

  ],
  "paths": {
  },
  "components": {
  }
}

Another point, - you never say how to generate the documentation except the below line:

OpenApi.write_docs

I ran it from rails consoleand it worked, is it correct.

I'm played around with a simple Rails API (rails 5.2.2) app containing Posts scaffolded ressource with active_model_serializers gem.

What am I missing ? Thank you!

undefined method `cattr_accessor' for OpenApi::Config:Module (NoMethodError)

Hello,

I'm trying to get zero-rails_openapi gem working on my Rails 3.2 project for generating nice OpenAPI documentation.

Unfortunately, I get the following error when trying to start the application (or console) after installation of the gem:

/Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/zero-rails_openapi-1.6.1/lib/open_api/config.rb:9:in `<module:Config>': undefined method `cattr_accessor' for OpenApi::Config:Module (NoMethodError)
Did you mean?  mattr_accessor
              attr_accessor
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/zero-rails_openapi-1.6.1/lib/open_api/config.rb:5:in `<module:OpenApi>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/zero-rails_openapi-1.6.1/lib/open_api/config.rb:4:in `<top (required)>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `require'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `require'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/zero-rails_openapi-1.6.1/lib/open_api.rb:2:in `<top (required)>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `require'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `require'
  from /Users/kwerdler/projects/blank-3.2.22.5/config/initializers/open_api.rb:2:in `<top (required)>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `load'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `block in load'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `load'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/engine.rb:592:in `each'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/engine.rb:592:in `block in <class:Engine>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/initializable.rb:30:in `instance_exec'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/initializable.rb:30:in `run'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/initializable.rb:55:in `block in run_initializers'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/initializable.rb:54:in `each'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/initializable.rb:54:in `run_initializers'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/application.rb:136:in `initialize!'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/railtie/configurable.rb:30:in `method_missing'
  from /Users/kwerdler/projects/blank-3.2.22.5/config/environment.rb:5:in `<top (required)>'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/application.rb:103:in `require'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/application.rb:103:in `require_environment!'
  from /Users/kwerdler/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-3.2.22.5/lib/rails/commands.rb:40:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

To make sure this wasn't caused by anything special in the project, I tried again with a freshly generated Rails 3.2.22.5 application by using Ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin17]. Unfortunately this yielded the same result.

Is there some incompatibility I'm not aware of? Please advise me.

Thanks in advance.

Response properties named type cause problems

In our specification we have a definition of an email, which has in it a property called type. This appears to cause hell in the generated spec.

A minimal example would be something like this::

schema :EmailSchema => [ 
  { 
    type: { 
      email: { type: String, desc: 'The email'}, 
      type: { type: String, desc: 'work/home' }
    },
    desc: 'an email object'
  }
]

This produces:

"EmailSchema": {
  "type": "string",
  "email": {
    "type": "String",
    "desc": "The email"
  },
  "description": "an email object"
}

But it should produce something like:

"EmailSchema": {
  "type": "object",
  "properties": {
    "email": {
      "type": "String",
      "desc": "The email"
    },
    "type": {
      "type": "String",
      "desc": "work/home"
    },
  }
  "description": "an email object"
}

Any thoughts?

Backup Log

api_dry: documentation

Previously you could do:

  api_dry :all do
    path :app_id, String, desc: "App ID for the Tab"
  end

And it would add this to all of the responses. It looks like now you have to also put dry in each block?

  api(:show, "Get a single App Tab", id: "AppTabShow") do
    dry
    param :path, :id, Integer, :req, desc: 'ID of App Tab to show'

    response '200', 'success', :json, data: :AppTab
  end

The documentation has a link to detailed info but that link goes to a 404:

https://github.com/zhandao/zero-rails_openapi#5-api_dry-optional

Should the dry need to be added to each call? Or is this a regression?

PS: Sorry in advance if I post a few questions. The upgrade to v2 has made a lot of changes to the generated spec file.

Help with descriptions in schemas

I'm having trouble getting properties in schemas to have descriptions. When I call schema I pass a name and a hash as the type.

Something a bit like this:

definition = {
  email: {
    id: 'Integer',
    email: 'String',
    type: 'String',
    is_primary: 'Boolean'
  }
}

schema(Email, definition, desc: 'An email')

Looking at https://github.com/zhandao/zero-rails_openapi/blob/master/lib/oas_objs/schema_obj_helpers.rb#L8 I should be able to add descriptions to each property, but I can't get it to work.

What do i have to do to give properties in a schema object a description?

config option for additionalProperties on false by default

Hi,

Thanks for writing this library !

Got used to most of the DSLs provided and was wondering if there is a way to configure additionalProperties to be implicitly false on all schemas/subschemas if not specified.

I'd like to be able to either configure it globally in the configuration file or in a schema object and have it applied on all schemas that are nested.

OpenApi.write_doc failing for routes.

Error Stack

Uncaught exception: undefined method `match?' for #<String:0x007fe9c6186e80>
Did you mean?  match
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:88:in `block in routes_list'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:87:in `map'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:87:in `routes_list'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/dsl.rb:67:in `ctrl_routes_list'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/dsl.rb:39:in `api'
	/Users/sonamgup/work_dir/orca/app/controllers/api/services_controller.rb:12:in `<class:ServicesController>'
	/Users/sonamgup/work_dir/orca/app/controllers/api/services_controller.rb:1:in `<top (required)>'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:457:in `load'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:457:in `block in load_file'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:647:in `new_constants_in'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:456:in `load_file'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:354:in `require_or_load'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:494:in `load_missing_constant'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:184:in `const_missing'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:263:in `const_get'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:263:in `block in constantize'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:259:in `each'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:259:in `inject'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:259:in `constantize'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:19:in `block in generate_docs'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:18:in `each'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:18:in `generate_docs'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/zero-rails_openapi-1.5.7/lib/open_api/generator.rb:54:in `write_docs'
	/Users/sonamgup/work_dir/orca/config/initializers/open_api.rb:19:in `<top (required)>'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/engine.rb:652:in `block in load_config_initializer'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.8/lib/active_support/notifications.rb:166:in `instrument'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/engine.rb:651:in `load_config_initializer'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/engine.rb:615:in `each'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/engine.rb:615:in `block in <class:Engine>'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `instance_exec'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `run'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/initializable.rb:44:in `each'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/initializable.rb:44:in `tsort_each_child'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:415:in `call'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `call'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
	/Users/sonamgup/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/initializable.rb:54:in `run_initializers'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/application.rb:352:in `initialize!'
	/Users/sonamgup/work_dir/orca/config/environment.rb:5:in `<top (required)>'
	/Users/sonamgup/work_dir/orca/config.ru:3:in `require'
	/Users/sonamgup/work_dir/orca/config.ru:3:in `block in <main>'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/builder.rb:55:in `instance_eval'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/builder.rb:55:in `initialize'
	/Users/sonamgup/work_dir/orca/config.ru:in `new'
	/Users/sonamgup/work_dir/orca/config.ru:in `<main>'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/builder.rb:49:in `eval'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/builder.rb:49:in `new_from_string'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/builder.rb:40:in `parse_file'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/server.rb:300:in `build_app_and_options_from_config'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/server.rb:209:in `app'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/server.rb:61:in `app'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/rack-1.6.10/lib/rack/server.rb:337:in `wrapped_app'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/server.rb:139:in `log_to_stdout'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/server.rb:78:in `start'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:80:in `block in server'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:75:in `tap'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:75:in `server'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	/Users/sonamgup/.rvm/gems/ruby-2.3.4/gems/railties-4.2.8/lib/rails/commands.rb:17:in `<top (required)>'
	/Users/sonamgup/work_dir/orca/bin/rails:9:in `require'
	/Users/sonamgup/work_dir/orca/bin/rails:9:in `<top (required)>'

Is there anything I should be careful of when I use devise together?

Hi!

I was googling around for OAS 3.0 gems like this gem.
Thanks for writing such library!

I really want to try it but suddemly I got a problem.
The error appears when I try to do rails c or run a server by rails s

Here is the infomation.

Traceback
Traceback (most recent call last):
        112: from bin/rails:4:in `'
        111: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
        110: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
        109: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
        108: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        107: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        106: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        105: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        104: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        103: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `'
        102: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/command.rb:46:in `invoke'
        101: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/command/base.rb:69:in `perform'
        100: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
         99: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
         98: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
         97: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/commands/console/console_command.rb:101:in `perform'
         96: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
         95: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/command/actions.rb:28:in `require_environment!'
         94: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/application.rb:339:in `require_environment!'
         93: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
         92: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
         91: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
         90: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
         89: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
         88: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
         87: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
         86: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
         85: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
         84: from /mnt/c/Users/spb82/Documents/GitHub/api.main/config/environment.rb:5:in `'
         83: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/application.rb:363:in `initialize!'
         82: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:60:in `run_initializers'
         81: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
         80: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
         79: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
         78: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:347:in `call'
         77: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:347:in `each'
         76: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
         75: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
         74: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:415:in `call'
         73: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in `tsort_each_child'
         72: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in `each'
         71: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
         70: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
         69: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
         68: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
         67: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
         66: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
         65: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `run'
         64: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `instance_exec'
         63: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/engine.rb:623:in `block in '
         62: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/engine.rb:623:in `each'
         61: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/engine.rb:624:in `block (2 levels) in '
         60: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/engine.rb:666:in `load_config_initializer'
         59: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/notifications.rb:182:in `instrument'
         58: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/railties-6.0.2.1/lib/rails/engine.rb:667:in `block in load_config_initializer'
         57: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:319:in `load'
         56: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
         55: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:319:in `block in load'
         54: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
         53: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
         52: from /mnt/c/Users/spb82/Documents/GitHub/api.main/config/initializers/open_api.rb:14:in `'
         51: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api.rb:17:in `write_docs'
         50: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api.rb:29:in `generate_docs'
         49: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api.rb:63:in `traverse_controllers'
         48: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api.rb:63:in `each'
         47: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api.rb:64:in `block in traverse_controllers'
         46: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/core_ext/string/inflections.rb:68:in `constantize'
         45: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/inflector/methods.rb:280:in `constantize'
         44: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/inflector/methods.rb:280:in `inject'
         43: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/inflector/methods.rb:280:in `each'
         42: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/inflector/methods.rb:284:in `block in constantize'
         41: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/inflector/methods.rb:284:in `const_get'
         40: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:214:in `const_missing'
         39: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `load_missing_constant'
         38: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:17:in `allow_bootsnap_retry'
         37: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:61:in `block in load_missing_constant'
         36: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:545:in `load_missing_constant'
         35: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `require_or_load'
         34: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:17:in `allow_bootsnap_retry'
         33: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:49:in `block in require_or_load'
         32: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:390:in `require_or_load'
         31: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:40:in `load_interlock'
         30: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
         29: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
         28: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
         27: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:40:in `block in load_interlock'
         26: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:407:in `block in require_or_load'
         25: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:510:in `load_file'
         24: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:702:in `new_constants_in'
         23: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:511:in `block in load_file'
         22: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
         21: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
         20: from /mnt/c/Users/spb82/Documents/GitHub/api.main/app/controllers/v2/answers_controller.rb:1:in `'
         19: from /mnt/c/Users/spb82/Documents/GitHub/api.main/app/controllers/v2/answers_controller.rb:7:in `'
         18: from /mnt/c/Users/spb82/Documents/GitHub/api.main/app/controllers/v2/answers_controller.rb:10:in `'
         17: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api/dsl.rb:36:in `api'
         16: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api/router.rb:28:in `routes_list'
         15: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zero-rails_openapi-2.1.4/lib/open_api/router.rb:14:in `routes'
         14: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
         13: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:289:in `load_dependency'
         12: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:702:in `new_constants_in'
         11: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:289:in `block in load_dependency'
         10: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
          9: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
          8: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
          7: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
          6: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
          5: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
          4: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
          3: from /mnt/c/Users/spb82/Documents/GitHub/api.main/config/routes.rb:1:in `'
          2: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:412:in `draw'
          1: from /home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/devise-4.7.1/lib/devise/rails/routes.rb:19:in `finalize!'
/home/eric/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/devise-4.7.1/lib/devise.rb:473:in `configure_warden!': undefined method `failure_app=' for nil:NilClass (NoMethodError)
config/application.rb
require_relative 'boot'

require "rails"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_view/railtie"

Bundler.require(*Rails.groups)

module BaseAPI
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0

config.api_only = true

# Internationalization
I18n.available_locales = [:en, :ko]
config.encoding = "utf-8"
config.time_zone = "Seoul"
config.i18n.default_locale = :ko

# Annotations
config.annotations.register_directories("engines")
config.annotations.register_tags("TESTME")

end
end

config/initializers/open_api.rb
require 'open_api'

OpenApi::Config.class_eval do
self.file_output_path = './'

open_api :some_api, base_doc_classes: [V1::BaseController]
info version: '1.0.0', title: 'API', description: "API"
end

OpenApi.write_docs if: !Rails.env.production?

config/routes.rb
Rails.application.routes.draw do
  namespace :v1, defaults: { format: :json } do
    resources :achievements do
    end
    resources :answers do
    end
    resources :boards do
      member do
        get :posts
      end
    end
    resources :branches do
    end
    resources :categories do
    end
. . . 

resources :themes do
end
resources :tokens do
end
resources :topics do
  member do
    get :super_themes
  end
end
resources :variables do
end
resources :view_types do
end

end
end

Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.0'

gem 'rails', '~> 6.0.2'
gem 'puma', '~> 4.3'
gem 'bootsnap', '>= 1.4.5', require: false

group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
gem 'listen', '>= 3.1.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rack-attack' # https://github.com/kickstarter/rack-attack
gem 'rack-cors' # https://github.com/cyu/rack-cors
gem 'config' # https://github.com/railsconfig/config
gem 'jwt' # https://github.com/jwt/ruby-jwt
gem 'mysql2'
gem 'fast_jsonapi' # https://github.com/Netflix/fast_jsonapi
gem 'rails-i18n', '~> 6.0.0'
gem "globalize", "~> 5.3.0"
gem "enumerize", "~> 2.3.0"
gem "fast_jsonapi", "~> 1.5.0"
gem "devise"
gem "google-api-client", "~> 0.36"
gem 'pagy', '~> 3.7.0' # https://github.com/ddnexus/pagy
gem "aws-sdk-s3", require: false
gem 'zero-rails_openapi' # https://github.com/zhandao/zero-rails_openapi/

I think there is nothing special in my code. so I wonder there is anything I shoud be careful of using devise gem together.
I will appreciate for any help. :)

Missing `/` in reference

Missing / in reference. The generated parameters "$ref" keys should start with #/ but they only start with #.

  components do
    query! DeviceQuery:  [ :device_platform, String,   enum: %w[ios android], desc: 'Users device platform.' ]
    query! UdidQuery:    [ :device_udid,     String,   desc: 'Users unique device id. Generate a UUID on device.' ]
end

  api :show, 'This API gets the top level app metadata' do
    param_ref :DeviceQuery
    param_ref :UdidQuery
  end

Output:

"parameters": [
          {
            "$ref": "#components/parameters/DeviceQuery"
          },
          {
            "$ref": "#components/parameters/UdidQuery"
          }
        ]

Expected:

"parameters": [
          {
            "$ref": "#/components/parameters/DeviceQuery"
          },
          {
            "$ref": "#/components/parameters/UdidQuery"
          }
        ]

https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#referenceObject

Not an issue, need suggestion

Currently, we have configured response as a static code, and whenever we do amendment in our code, we have to do change in the response part as well, can we set response as dynamic, instead of static?

Could you please let me know, how we can set response dynamic in docs.

api :show, 'GET the specified user' do #, builder: :show#, use: id
    query 'id', Integer  #, range: { ge: 1 }, default: 1
    response 200, :success, 'application/vnd.api+json', data: { data: [{id: 1}] }    
  end

components are not created when not in the same controller

Hi again,
if I include my component directly in the controller using it, the component is generated in the json file but not if I include the component in the base controller.

Here the case working:

class Api::ApiController < ActionController::API
end
class Api::ReservationRequestsController < Api::ApiController
  components do
    query! reservation_request_type: [ :type, String ]
  end

  api :create do
    param_ref :reservation_request_type
  end
  def create
  end
end

Here the case not working:

class Api::ApiController < ActionController::API
  components do
    query! reservation_request_type: [ :type, String ]
  end
end
class Api::ReservationRequestsController < Api::ApiController
  api :create do
    param_ref :reservation_request_type
  end
  def create
  end
end

I have no error, I both case I have this in the JSON file:

    "/api/reservation/requests": {
      "post": {
        "operationId": "create",
        "tags": [
          "ReservationRequests"
        ],
        "parameters": [
          {
            "$ref": "#components/parameters/reservation_request_type"
          }
        ]
      }

but this part is missing:

  "components": {
    "parameters": {
      "reservation_request_type": {
        "name": "type",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    }
  }

Multiple API Specs in same project?

Is there a way to generate 2 separate API specs in the same Rails project? We have 2 separate API's (different end points, different authentication, etc) that we want to generate 2 separate documents for.

Is there a way to specify a `default` response

I've tried a few things but I keep getting met with *** ArgumentError Exception: comparison of Array with Array failed

  api :index, 'Return a list of resources for which the caller has access.', id: :listResources do
    dry
    
    response 200, 'Resource list.', :json, data: {},
      type: 'array',
      items: {
        '$ref': '#/components/schemas/Resource'
      }
      byebug
    response :default, 'Default', :json, data: { },
      '$ref':'#/components/schemas/Error'
    end

   # This doesn't work either
   response_ref :default => :Default
end

This is the state of the app using byebug

[134, 143] in /usr/local/bundle/gems/zero-rails_openapi-2.1.2/lib/open_api/dsl/api.rb
   134:         dry() if dry
   135: 
   136:         self[:parameters].map!(&:process)
   137:         self[:requestBody] = self[:requestBody].try(:process)
   138:         self[:responses].each { |code, response| self[:responses][code] = response.process }
=> 139:         self[:responses] = self[:responses].sort.to_h
   140:         self.delete_if { |_, v| v.blank? }
   141:       end
   142:     end
   143:   end
(byebug) self[:responses]
{200=>{:description=>"Resource list.", :content=>{"application/json"=>{:schema=>{:type=>"array", :items=>{:$ref=>"#/components/schemas/Resource"}}}}}, :default=>{:description=>"Default", :content=>{"application/json"=>{:schema=>{:type=>"object", :$ref=>"#/components/schemas/Error"}}}}}
(byebug) self[:responses].sort
*** ArgumentError Exception: comparison of Array with Array failed

If I switch :default to any number the error is resolved.

operationID not unique

The operationId being output is currently the action name of the controller. According to the docs:

"operationId: string - Unique string used to identify the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions."

As multiple controllers may have index, show methods, etc. then this outputs duplicate operationID's. It would be good if:

  1. The default was #{controller_name}_#{action}
  2. You could set this in the api call

Allow title to be added to response object

I'm trying to add a title to a response object like the below example. I don't think the response signature currently supports that? Is there a workaround?

# method signature
response(code, desc, media_type = nil, data: { }, type: nil)
     "responses": {
          "200": {
            "description": "success",
            "content": {
              "application/json": {
                "schema": {
                  "title": "MediaItemsGetResponse",
                  "type": "object",
                  "properties": {
                    "accountId": {
                      "type": "integer"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PageMeta"
                    },
                    "mediaItems": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MediaItem"
                      }
                    }
                  }
                }
              }
            }
          }
        }

NoMethodError: undefined method `oas' for ApplicationResource:Class

[2] [iam][development][development] pry(main)> OpenApi.write_docs
NoMethodError: undefined method oas' for ApplicationResource:Class from /Users/amitagarwal/.rvm/gems/ruby-2.6.0/gems/zero-rails_openapi-2.1.0/lib/open_api.rb:37:in block in generate_doc'
[3] [iam][development][development] pry(main)>

Document Associative Arrays

To output this:

name: {
  "en": "The Broad"
  "de": "De Broad"
}

We should be using a Dictionaries, HashMaps and Associative Arrays

This uses the additionalProperties but deifning this doesn't seem to work:

name: {type: Object, additionalProperties: String}

Outputs

"name": {
  "type": "object"
}

But should output (I think):

"name": {
  "type": "object"
  "additionalProperties" {
    "type": "string"
  }
}

Trouble generating schema when resource uses `parms:`

It looks like the library has trouble handling resources where the parameter name has been overridden.

Rails.application.routes.draw do
  resources :parent do
    resources :child, param: :name
  end
end
root@5684fb4c5068:/var/app/current# rake open_api:generate
    OpenApi Route mapping failed: child#show
    OpenApi Route mapping failed: child#update
    OpenApi Route mapping failed: child#destroy
    OpenApi `schema.json` has been generated.

If I delete the param: :name the routes are generated as expected. Interestingly enough, it didn't error on the :index or :create actions.

Response schema validator

Hi,
I investigated openapi3 gems and seems like this one is doing a good job.
I wonder if there is an option to validate that response data in the test is in line with the response schema defined in the controller.

Ideally in request specs to have the ability to write something like this:

it 'validates response schema' do
  get '/api/v1/users'
  validate_response_schema(response_body: response.body, controller_action_for_which_we_are_validating_schema: 'users#index')
end

Of course, this code could be simplified but added for readability and to express intention.

Is there such a feature in this gem or is it planned? Any kind of direction is helpful.

ReDoc Vendor Extensions

I'm working on getting a spec generated with your tool to work nicely in ReDoc. Only problem I have is in the difficulty of getting some of the vendor extensions to be included in the spec - ideally this library should allow vendor extensions to be passed through.

Specifically, I need to use x-logo, x-tagGroups and x-displayName from here:
https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md

x-logo is easy as it can be added straight to the info DSL, e.g.:

info version: '1.0.0',
       title: 'Fake API',
       'x-logo': { url: BASE64_ENCODED_OR_URL, altText: 'ALT TEXT' },
...

x-tagGroups I've managed to add by injecting them to the generated document's hash before we render to JSON, which isn't pretty but it works. Something like this:

data = OpenApi.generate_docs
doc = data[:SPEC_IDENTIFIER]
doc[:'x-tagGroups'] = xTagGroupsHash
json = JSON.generate(doc)

x-displayName is the one that appears to be completely blocked by the code. Basically I'm doing something like this:

doc_tag name: tag, desc: I18n.t(tag.underscore), 'x-displayName': tag.titleize

But I get a unknown keyword: x-displayName error. I've also tried doing externalDocs as documented, but that fails in the same way. Any help on this/working around it would be great!

Warnings with Ruby v2.7.1

We're working toward updating our Rails project to Ruby v2.7.1, and when our project starts, we get these warnings:

/usr/local/bundle/gems/zero-rails_openapi-2.1.4/lib/oas_objs/request_body_obj.rb:21: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/bundle/gems/zero-rails_openapi-2.1.4/lib/oas_objs/media_type_obj.rb:12: warning: The called method `initialize' is defined here
/usr/local/bundle/gems/zero-rails_openapi-2.1.4/lib/oas_objs/response_obj.rb:23: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/bundle/gems/zero-rails_openapi-2.1.4/lib/oas_objs/media_type_obj.rb:12: warning: The called method `initialize' is defined here
/usr/local/bundle/gems/zero-rails_openapi-2.1.4/lib/open_api/dsl/helpers.rb:34: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/bundle/gems/zero-rails_openapi-2.1.4/lib/open_api/dsl/helpers.rb:27: warning: The called method `_combined_schema' is defined here

You can see the deprecation details here: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

Support for Boolean

I'm trying to specify a field as a Boolean:

  schema Collection: [
      {
        id: Integer,
        shortName: String,
        title: String,
        description: String,
        listLayout: {type: String, enum: ["wide", "grid", "list"] },
        headerLayout: {type: String, enum: ["short", "tall", "image"] },
        searchEnabled: Boolean,
        mapViewEnabled: Boolean,
        currentLanguage: String,
        primaryLanguage: String,
        translatedLanguages: { type: Array[{ type: String }] },
        coverImage: :MediaItemImage,
        coverImageGrid: :MediaItemImage
      },
      desc: "A Single Collection"
    ]

But I'm getting:

rake aborted!
NameError: uninitialized constant WriteApiDoc::Boolean

Should Boolean's be accepted here?

undefined method `red' for " ZRO":String

Hi,
I just created a rails 5.2 (rc2) application and added your gem and I have the following error in a empty controller:

undefined method `red' for " ZRO":String
Rails.root: /app

Application Trace | Framework Trace | Full Trace
zero-rails_openapi (1.5.6) lib/open_api/dsl.rb:39:in `api'
app/controllers/api/houseworks_controller.rb:5:in `<class:HouseworksController>'
app/controllers/api/houseworks_controller.rb:3:in `<main>'
bootsnap (1.2.1) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:84:in `load'
bootsnap (1.2.1) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:84:in `load'

Here my controllers:

require 'open_api/dsl'

class Api::ApiController < ActionController::API
  include OpenApi::DSL
end
class Api::HouseworksController < Api::ApiController
  api :index, 'GET list' do
  end
end

This is can fix if I add require 'colorize' in my HouseworksController.
I think you can avoid this by set the require in your lib.

Response headers produces invalid result

The addition of headers in responses (#42) is great, but it appears to produce properties that are not compliant with the OpenAPI specification.

Example output:

          headers:
            page:
              description: The current page
              schema:
                minimum: 1
                default: 1
                example: 2
                _enum: null
                _length: null
                _pattern: null
                _desc: null

The properties _enum, _length, _pattern, and _desc are invalid, and I believe they all come from https://github.com/zhandao/zero-rails_openapi/blob/master/lib/oas_objs/schema_obj.rb#L113, but I may be wrong. I've not yet traced back why these are bleeding through to the output though.

Small example of generating code:

headers = {
  page:  { desc: I18n.t('api.headers.page'), type: Integer, minimum: 1, default: 1, example: 2 }
}
response(200, 'Success', type, headers: headers, data: data)

NameError: uninitialized constant OpenApi::DSL::Helpers::ApplicationRecord

I have a basic API controller setup and trying to get the example to work:

class Api::V3::ApiController < ActionController::Base
  include OpenApi::DSL
end
class Api::V3::AppsController < Api::V3::ApiController
  api :show, 'GET item' do
    query :page, Integer
    query :rows, Integer
  end

  def show
    render :json => Api::V3::AppPresenter.new(@app)
  end
end

And in the Rails console:

[3] pry(main)> OpenApi.write_docs
NameError: uninitialized constant OpenApi::DSL::Helpers::ApplicationRecord
from ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/bundler/gems/zero-rails_openapi-3bed570a5acb/lib/open_api/dsl/helpers.rb:56:in `process_schema_info'

Any ideas of why this error might be happening or how to fix this?

Duplicate operationId's

When generating the docs the operationId is not unique for PUT and PATCH

So:

api(:update, "Update a single Collection") do
 ...

Generates both:

      "put": {
        "summary": "Update a single Collection",
        "operationId": "Collections_update",

and:

"patch": {
        "summary": "Update a single Collection",
        "operationId": "Collections_update",

Which throws errors in the code gen tool:

Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
 | Error count: 4, Warning count: 0
Errors:
	-attribute paths.'/api/frontend_v2/user'(patch).operationId is repeated
	-attribute paths.'/api/frontend_v2/screens/{id}'(patch).operationId is repeated
	-attribute paths.'/api/frontend_v2/collections/{id}'(patch).operationId is repeated
	-attribute paths.'/api/frontend_v2/media_items/{id}'(patch).operationId is repeated

Not sure how to get around this?

Fails when trying to pass a Request Body with exp_params using the DSL

How to reproduce:

  • In a controller, set a request body like this (I left the data and examples empty because they don't matter) :
class DogsController < ApplicationController
      api :dogs, 'POST create a doggie' do
         request_body :req, :json, desc: '', data: {}, examples: {}, exp_params: :all
      end
end

Error is:

rails aborted!
NameError: undefined local variable or method `schema_type' for {}:OpenApi::DSL::MediaTypeObj
Did you mean?  schema

I think the problem is here on media_type_obj.rb:

class MediaTypeObj < Hash
  attr_accessor :media_type, :schema, :examples
      
    def initialize(media_type, hash)
      examples_hash   = hash.delete(:examples)
      exp_params      = schema_type.keys if (exp_params = hash.delete(:exp_params)) == :all
      self.examples   = ExampleObj.new(examples_hash, exp_params, multiple: true) if examples_hash.present?
      self.media_type = media_type_mapping(media_type)
      self.schema     = SchemaObj.new(hash.values_at(:type, :data).compact.first,
      hash.except(:type, :data))
end

schema_type is used to get the exp_params but it's not declared anywhere in the class.

Btw, if the bug report is correct, are you open to PRs? because I could create one for this change if you are ok with that.

Adding examples to parameters and schemas

Hi,

Is it possible to add an example to a field in a schema? I was not able generate a json file that looks similar to the ones described here: https://swagger.io/docs/specification/adding-examples/#schemas

In the snippet below, I would like to add an example to the medium_id field.

components do
  schema :medium => [
    {
      medium_id: { type: 'string', desc: 'the medium id; ex: 1577754239923912471_357658764' },
    },
    desc: 'medium record'
  ]
end

What about examples in parameters? (https://swagger.io/docs/specification/adding-examples/#parameters)

Thanks!

Cannot define schema for simple Hash

I am trying to define a schema for a semi-complex Object. But I am running into issue trying to define individual fields for it.
For example given a Hash for User which I want to define schema for

{
name: "John", 
permissions: ["READ", "WRITE"], 
contact: { email: "[email protected]", phone: "234-234-2344" }
}

I tried using components block with schema :User => [ ...many different variations...] but all I got in json output was

    "schemas": {
       "User": {
         "type": "object"
       }
     }

Is there an example how to define schema for a Hash?

Duplicate tags

I want to group multiple controllers under the same doc_tag.

I gave them the same doc_tag name: Resource and when I generate the doc I end up with:

"tags": [

    {

      "name": "Resource"

    },

    {

      "name": "Resource"

    },

    {

      "name": "Resource"

    },

    {

      "name": "Resource"

    }

How should I be grouping multiple controllers under a single tag?

Array type on Schema object does not support items.

Using a schema like this.
... type= { expiry!: String, bucket!: String, path!: String, metadata: {type: Object}, challenge: {type: 'array', items: {type: 'string'}} } or challenge: {type: Array, items: {type: 'string'}} ...
And an api like this.
... api :create, 'POST Link' do desc "Create a new upload link. Provide the standard criteria as well as extra meta information." body :json, data: type resp 201, 'Created Link', :json, data: {}, type: LINK_RESPONSE end ...
EXPECTED OUTPUT
`"challenge": {
"type": "array"
"items": {
"type": '"string"
}
}

ACTUAL OUTPUT
"challenge": { "type": "array" }

I'll put in a PR for this.

Uninitialized constant OpenApi::DSL::Helpers::ApplicationRecord

Hello,

First of all thank you for this gem and the time you have put into it. I am attempting to get this setup in a rails 5 api only app. The main problem is that I am using mongoid and therefore not using ActiveRecord or ApplicationRecord. When I add dsl to a controller I get Uninitialized constant OpenApi::DSL::Helpers::ApplicationRecord

I saw on a previous issue that you suggested adding config.active_record_base = ActiveRecord::Base but since I am not using ActiveRecord that causes other issues. Do you know of a way to get around this?

Thank you!

Fusion not working when using multiple body_ref

I am trying to use components for my body request, but it seems to not fusion them and just take the last component mentioned. If I don't use the components and use directly multiple request_body it works fine.

Here it works:

api :create_application, 'Create Application' do
request_body :opt, :form, data: {
   profiles_params: {
     type: {
       Id!: { type: Integer, desc: 'Id'},
       age: { type: Integer, desc: 'Age' },
     },
     desc: 'Profiles Parameters'
   }
 }
 request_body :opt, :form, data: {
   application_params: {
     type: {
       # user
       first_name: { type: String, desc: 'First Name' },
       last_name: { type: String, desc: 'Last Name' },
     },
     desc: 'Application Parameters'
   },
 }
end

And here it doesn't, only ApplicationParams will be used:

components do
  request_body :ProfileParams, :opt, :form, data: {
    profiles_params: {
      type: {
        Id!: { type: Integer, desc: 'Id'},
        age: { type: Integer, desc: 'Age' },
      },
      desc: 'Profiles Parameters'
    }
  }
  request_body :ApplicationParams, :opt, :form, data: {
    application_params: {
      type: {
        # user
        first_name: { type: String, desc: 'First Name' },
        last_name: { type: String, desc: 'Last Name' },
      },
      desc: 'Application Parameters'
    },
  }
end

api :create_application, 'Create Application' do
  body_ref :ProfileParams
  body_ref :ApplicationParams
end

It is normal behavior that fusion doesn't work for body refs or is there a syntax/workaround I haven't found ?

Also, the alias 'body' cannot be used to declare a component, I get a ' wrong number of arguments (given 3, expected 2)' error. Just wanted to note that since I struggle with it for a while.

Thanks!

Generating OpenAPI fails with Spring

To reproduce:

  1. Run OpenApi.write_docs in rails console
  2. Make some changes to your specification and reload console
  3. Run OpenApi.write_docs again.

Now, you will either 1) Get no paths in your schema, or 2) only get some components.

Solution:

  • spring stop and run OpenApi.write_docs again.
  • or you can change the "homepage" key to another key in the initializers/openapi.rb file, and it will also work.

I think maybe it's because of the bang in

(doc_name || Config.docs.keys).map { |name| { name => generate_doc(name) } }.reduce({ }, :merge!)
which maybe causes Config.docs['homepage'] to be overwritten, so the next time it tries to generate, this is not properly configured anymore?

OpenApi.write_docs does not generate API documentation from controller

Running OpenApi.write_docs doesn't generate any documentation in my project.

I have the following project structure:

app
- controllers
  - api
    - v1
      - units_controller.rb
    - application_controller.rb
  - application_controller.rb

My initializer:

# config/initializers/open_api.rb
require "open_api"

OpenApi::Config.class_eval do
  # Part 1: configs of this gem
  self.file_output_path = "public/apidocs"

  # Part 2: config (DSL) for generating OpenApi info
  open_api :apidoc, base_doc_classes: [API::ApplicationController]
  info version: "0.0.1", title: "APIs" #, description: ..
  server "http://api.localhost:3000", desc: "Internal staging server for testing"
end

This is my routes file:

# config/routes.rb
require "api_constraints"

Rails.application.routes.draw do
  root "home#index"
  get "home/index"

  namespace :api, path: "", constraints: { subdomain: "api" }, defaults: { format: "json" } do
    namespace :v1, path: "", constraints: APIConstraints.new(version: 1, default: true) do
      resources :units, only: [:index, :create]
    end
  end
end

  resources :locations do
    resources :units do
      resources :recipients, shallow: true
    end
  end

The controller for the API:

# app/controllers/api/v1/application_controller.rb
class API::ApplicationController < ActionController::API
  include OpenApi::DSL
end

The units API controller:

# app/controllers/api/v1/units_controller.rb
class API::V1::UnitsController < API::ApplicationController
  before_action :get_location

  api :index, "GET list of Units", http: "GET" do
    param :query, :location_id, Integer, :req, range: { gt: 0, le: 99999 }, desc: "location id"
  end

  def index
    @units = @location.units
  end

.
.
.

When I run OpenApi.write_docs using a rake task:

ruby@b4b89614c6c5:/app$ bundle exec rails apidocs:generate
Generating...
    OpenApi loaded
    OpenApi `apidoc.json` has been generated.

The resulting file:

# public/apidocs/apidoc.json
{
  "openapi": "3.0.0",
  "info": {
    "version": "0.0.1",
    "title": "APIs",
    "description": ""
  },
  "servers": [
    {
      "url": "http://api.localhost:3000",
      "description": "Internal staging server for testing"
    }
  ],
  "security": [

  ],
  "tags": [

  ],
  "paths": {
  },
  "components": {
  }
}

Any idea why my json document is empty?

Multiple components blocks

I want to separate components into multiple files without duplicating them, so I have some modules that define response_refs and param_refs, and then I include these helpers.

It seems like only the last components do ... end will be evaluated, and all the ones before will be overwritten.

Is there a way I can define components in multiple files?

Use of "&." requires Ruby 2.3

We tried using zero-rails_openapi in our project but it fails on the instances of the "&." operator in generator.rb because our project is still using Ruby 2.2. Would you consider adding a s.required_ruby_version = '>= 2.3' to the gemspec to make the required version explicit?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.