exoego / exoego/rspec-openapi

API schema that is not subject to rspec execution is deleted.

Open
#85 1 comment 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Ruby
Stars
509
Forks
76
Avg merge
12h 46m
Merged PRs (30d)
16

Description

When running `OPENAPI=1 rspec spec/requests/samples_spec.rb:15` is run, the schema that is not under test is also deleted.

request spec
```ruby
describe 'Sample API TEST', :api_admin, type: :request do
let(:headers) { { headersample: "headersample" } }
let(:sample) { create(:sample, name: "srockstyle") }
let(:params) { { } }

before do
restaurant
end
it 'Test A' do
get "/v1/sample", headers: headers, params: params
expect(response).to(have_http_status(200))
end

it 'Test B' do
get "/v1/sample/#{sample.id}", headers: headers, params: params
expect(response).to(have_http_status(200))
end
end
```

openapi.yaml created after running `OPENAPI=1 rspec spec/requests/samples_spec.rb`
```yaml
---
openapi: 3.0.3
info:
title: app
version: 1.0.0
servers: []
paths:
"/v1/samples":
post:
summary: index
tags:
- Sample
parameters:
- name: id
in: path
required: true
schema:
type: integer
example: 1
responses:
'200':
description: Index sample
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
example:
- id: 1
name: srockstyle
job: sample
"/v1/samples/{id}":
post:
summary: index
tags:
- Sample
responses:
'200':
description: Index sample
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
type: string
example:
id: 1
name: srockstyle
job: sample
```

Then spec was specified on a line and the command was executed `OPENAPI=1 rspec spec/requests/samples_spec.rb:10`,
yaml left only the specified parts and deleted the parts that were not specified.
```yaml
---
openapi: 3.0.3
info:
title: app
version: 1.0.0
servers: []
paths:
"/v1/samples":
post:
summary: index
tags:
- Sample
parameters:
- name: id
in: path
required: true
schema:
type: integer
example: 1
responses:
'200':
description: Index sample
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
example:
- id: 1
name: srockstyle
job: sample
```

I expect the following behavior, are there any options?
- Do not delete schema that is not to be executed
- get request" is processed as "post request", so we want to treat it as "get".

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.