Questions tagged [rswag]
52 questions
1
vote
1 answer
How create nested object in the rswag?
I wanted to create a documentation with swagger and rails following the json api specification.
My code:
require 'swagger_helper'
describe 'Blogs API' do
path '/blogs' do
post 'Creates a blog' do
tags 'Blogs'
…

Davi Luis
- 396
- 3
- 16
1
vote
1 answer
rails gem rswag custom parameter
How do I add a custom parameter in my rswag-specification?
Rswag seems to consumate only parameters which exists as fields
but I need to add a custom parameter. So whatever I do - I can see in controllers params only fields of my…

Unkas
- 3,522
- 2
- 19
- 23
1
vote
1 answer
Rswag: Authorization header appeared in query parameter
Version: rswag (2.0.5), rspec (3.8.0)
Environment: Rails 5.2.3, Ruby 2.4.5
It is my first time to use it, was stuck in authorization header for a day.
Here is what I did:
# in spec/swagger_helper.rb
config.swagger_docs = {
…

JohnZhang
- 191
- 5
- 15
1
vote
1 answer
How to generate swagger without writing spec files
I am looking for a gem which will generate swagger doc and showed it on the swagger UI, I came across rswag gem but it requires spec file needs to be present for generating the swagger doc
Is there any gem that will auto generate swagger doc if I…

hepzi
- 435
- 4
- 17
0
votes
0 answers
send from the UI a nested object file
put('test') do
parameter name: :params, in: :body, schema: {
type: :object,
properties: {
certificate: { type: :file, in: :formData }
},
}
}
end
put('test nested') do
parameter name: :params, in: :body, schema: {
type:…

Cephas
- 47
- 1
- 1
- 7
0
votes
1 answer
test returning pdf with swagger in ruby on rails
I'm trying to test an endpoint that returns a pdf file.
My action looks like this:
def pdf
respond_to do |format|
format.pdf do
@pdf = ApplicationController.render pdf: some_number,
template:…

Hessah
- 192
- 3
- 12
0
votes
1 answer
Multiple dock in one project with rswag rails
I try to create 2 docs for my api. I have 2 namespaces in routes and I need to create 2 docs for my first namespace and second namespace. In request test they are divided on 2 folders. How can I automatically generate this 2 docs and what i need to…

valduane
- 36
- 4
0
votes
1 answer
Rails rswag - override default server to provide a different base URL
The API I am working with has a few endpoints to be routed through VeryGoodSecurity for PCI compliance.
It does seem as though OpenAPI V3 supports overriding servers as mentioned in this page
The global servers array can be overridden on the path…

Ziyan Junaideen
- 3,270
- 7
- 46
- 71
0
votes
0 answers
Rswag does not recognize request_body_example
I'm using RSwag (2.7) to generate API documentation based on tests on Rails 6.1. The problem is that using the same method specified in the official documentation I get an RSpec error.
I need to add a pretty complex request body and the…
0
votes
1 answer
Rswag and FactoryBot - how to make them play nicely?
I am trying to write an Rswag test for some ActiveRecord validation against the account of a newly created record.
The issue I am having is that I can't work out how to create an Account using FactoryBot and then have it still exist when the test…

Stacker
- 1
- 2
0
votes
0 answers
rswag disallow properties not specified
I would like to specify in my rswag schema definition to only allow the properties that are defined in the schema, and strictly fail with a 500 similar to how it fails if required properties are missing.
So in this example it will fail with a 500 if…

bigtunacan
- 4,873
- 8
- 40
- 73
0
votes
1 answer
Make rspec more DRY by accessing let variable in describe block
I'm trying to DRY up rspec tests that keeps on declaring let(:createBody) do...end. I thought to take out the let statement and just modify the variable on each block as needed. However the variable (createBody) is not accessible. Added a comment on…

nakakapagpabagabag
- 327
- 6
- 15
0
votes
0 answers
Using Response Headers in First Response for Request Headers in Second Request
I'm migrating from postman to rspec/rswag for API documentation and testing.
I can get a simple example working that requires no auth, but for endpoints that require a login I'm unsure how to proceed.
In postman, I would create a test which…

atg
- 127
- 2
- 13
0
votes
0 answers
cannot load such file -- multi_json (LoadError)
After successfully doing bundle when I run this command to generate rswag helper "rails g rswag:install" produces the error
cannot load such file -- multi_json (LoadError)
I have tried to delete and create the project again and again, also after…

Almas Asghar
- 1
- 1
0
votes
1 answer
RSpec mock health endpoint failing due to database error
I have a health endpoint that will check if the database connection is working:
class HealthController < ApplicationController
def health
User.any? # Force a DB connection to see if the database is healthy
head :ok
rescue StandardError
…

Athix
- 37
- 1
- 9