Questions tagged [rswag]
52 questions
7
votes
1 answer
Rails rswag auto generation of examples not working
I have a rails 6 project and am trying to document the API using swagger and the rswag gem.
My rspec spec for the controller is as follows:
require 'swagger_helper'
RSpec.describe 'api/v1/books', type: :request do
let!(:book1) { create :book }
…

mark.sack
- 89
- 2
- 6
7
votes
1 answer
How create with rswag following the json api specification?
I didn't find any examples of how to use rswag to generate documentation according to json api.
spec/integration/pets_spec.rb
require 'swagger_helper'
It is possible to change the code to generate the format of json api?
describe 'Pets API' do
…

Davi Luis
- 396
- 3
- 16
6
votes
1 answer
Rswag schema does not fail for invalid properties of object in array
I have the following rswag test:
response '200', 'response with array of objects' do
schema type: :array,
items: {
type: :object,
properties: {
expected_id: { type: "integer", format: "int32" },
}
…

iftheshoefritz
- 5,829
- 2
- 34
- 41
5
votes
2 answers
Following JSON Api with rswag
I'm using rswag to test a rather common RubyOnRails JSON Api application, but I can't figure out a rather common case where I upload a file to an endpoint.
The endpoint expects the usual data attribute in the request body with a file attribute…

ngw
- 1,222
- 1
- 14
- 34
4
votes
1 answer
rspec_api_documentation - How to have multiple examples
My goal is to show multiple examples of parameters and responses using rspec_api_documentation with rswag-ui or by adding swagger-ui directly to the project. I'm having some trouble generating the correct open_api.json with my config and am…

isuPatches
- 6,384
- 2
- 22
- 30
4
votes
1 answer
when running rspec for rswag, key and value join together in the parameters as key and value become nil?
get 'customer' do
security [Token: []]
parameter name: :params, in: :body, schema: {
type: :object,
properties: {
search: { type: :string, example: Faker::Name.first_name }
}
}
…

Alireza mohagheghi
- 169
- 2
- 10
4
votes
2 answers
rswag gem does not recognize my parameters in rspec
when running RSpec, in the action of controller,(use byebug or pry)
the specific value like (email or password) did not exist in the request parameters,
and so the result of the test become failed
for more details, see my below code
path…

ayza
- 119
- 10
3
votes
0 answers
OpenAPI 3.0.3 documentation with RSwag Unable to Send "Content-Type" header
For my Rails project I am using RSwag to generate documentation using OpenAPI 3.0.3 specifications.
I know with Open API 3.0.3 'If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be…

jl118
- 307
- 2
- 16
3
votes
1 answer
Rspec swagger(openapi 3) error: '/components/responses' does not exist on schema
Using gem rswag-specs (2.3.1). Defined responses among components according to https://swagger.io/docs/specification/components/ :
config.swagger_docs = {
'swagger.yaml' => {
openapi: '3.0.1',
info: {
title: 'title',
},
…

Sergii Brytiuk
- 345
- 1
- 12
3
votes
1 answer
How to set a bearer token param for testing a Rails API using Rswag UI
I'm having issues when testing my API using the Rswag UI gem. It seems that authorization headers are not being set properly in the UI after entering the token in the param field. Nevertheless, the test itself is passing and the endpoint is being…

SgtPepper
- 418
- 6
- 18
3
votes
1 answer
Rails Rswag Swagger UI Not Sending Headers Properly
I'm using gem rswag for documentation for my Rails API. My rails API requires that all requests include headers['Content-Type']='my-fancy-content-type' and headers['Accept']='my-fancy-accept. So far I've done testing using POSTMAN and all are…

Johnson Liu
- 87
- 2
- 8
2
votes
1 answer
Rswag not adding schema into response
I'm using the RSwag gem to create swagger OpenAPI specs: https://github.com/rswag/rswag
And I'm trying to get the schema for the response to appear in the Swagger API docs that are generated with the following spec:
path '/api/v2/ping' do
…

Cameron
- 27,963
- 100
- 281
- 483
2
votes
1 answer
How we pass the headers inside swagger rspecs
I'm getting this error when I run the rspec
Response body: {"success":false,"errors":["Invalid login credentials"]}
here is my code
path '/api/auth/validate_token' do
get 'check token' do
tags 'TokenValidations'
consumes…

djadam
- 649
- 1
- 4
- 20
2
votes
1 answer
Rails request spec - undefined method `body' for nil:NilClass (rswag)
I'm trying to generate API documentation with rwsag, and I'm confused about a couple of my specs failing.
Here is my request spec:-
require 'swagger_helper' ### this includes 'rails_helper'
RSpec.describe 'api/v1/users', type: :request do
…

s89_
- 1,533
- 3
- 25
- 40
2
votes
2 answers
Problem with Rspec testing sign_in (Devise) with Request and rswag
I was tempted to use rswag with rspec to document REST API and write test at the same time.
I am trying to fallow tutorials and documentations but I cannot get sign_in endpoint working ( devise - session ).
When I do run rspec than I receive status…

BlueConga
- 887
- 9
- 19