Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger_doc tag doesn't work #43

Closed
zddhub opened this issue Mar 25, 2019 · 3 comments
Closed

swagger_doc tag doesn't work #43

zddhub opened this issue Mar 25, 2019 · 3 comments

Comments

@zddhub
Copy link

zddhub commented Mar 25, 2019

As comments or rswag (rspec-rails-swagger based on rswag):

By default, the operations defined in spec files are added to the first document below. You can override this behavior by adding a swagger_doc tag to the the root example_group in your specs, e.g.

describe '...', swagger_doc: 'v2/swagger.json'

But it doesn't work if I used it with RSpec, like below:

RSpec.describe 'mock allocation summary', type: :request, swagger_doc: 'v2/swagger.yml' do
...
    path '/post' do
...
end

Is there anybody have some idea?

@zddhub
Copy link
Author

zddhub commented Mar 25, 2019

Got some idea from source code

name = metadata[:swagger_document]

I found a workaround way:

RSpec.describe 'mock allocation summary', type: :request, swagger_doc: 'v2/swagger.yml' do
...
    path '/post', swagger_document: 'v2/swagger.yml' do
...
end

It works but not perfect ???

@drewish
Copy link
Owner

drewish commented Mar 29, 2019

Ah yeah I would have though it would work the way you expected. Looking at the helper:

swagger_document: attributes[:swagger_document] || RSpec.configuration.swagger_docs.keys.first,

It seems like it should looking for a document in the following order:

  • attributes hash passed in to the path call
  • metadata passed down from the parent context block
  • default to the first of the documents

So I'll look at adding a PR to fix this.

@drewish
Copy link
Owner

drewish commented Apr 1, 2019

Give #45 a look and see how that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants