-
Notifications
You must be signed in to change notification settings - Fork 64
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
"format" in path parameter #8
Comments
It's hard to understand the problem without code. Could you provide a request spec and/or a repository which reproduces the issue, and expected OpenAPI schema generated by that? |
Here is the repository. Step to reproduce: $ git clone git@github.com:natsuokawai/rspec-openapi-sample.git
$ cd rspec-openapi-sample
$ bundle install
$ rm doc/openapi.yaml
$ OPENAPI=1 bundle exec rspec spec/requests/api/posts_spec.rb In this repository, I configure routes file like this: Rails.application.routes.draw do
namespace :api, format: 'json' do
resources :posts, only: %i(index)
end
end
...
paths:
"/api/posts":
get:
summary: 'api/posts #index'
parameters:
- name: format
in: path
required: true
schema:
type: string
example: json
- name: title
in: query
schema:
type: string
example: f
... The generated file has a openapi: 3.0.3
info:
title: rspec-openapi-sample
paths:
"/api/posts":
get:
summary: 'api/posts #index'
parameters:
- name: format
in: path
required: true
schema:
type: string
example: json
- name: title
in: query
schema:
type: string
example: f
responses:
'200':
description: get posts
content:
application/json:
schema:
type: object
properties:
posts:
type: array
items:
type: object
properties:
title:
type: string
example:
posts:
- title: foo |
Thanks for providing the repository.
...
parameters:
- name: format
in: path
required: true
schema:
type: string
example: json
... What you expect also includes |
I pushed a new version v0.3.2 which I believe fixes the issue. Could you try that? |
I have tried the new version and confirmed that this problem is no longer occurring. Thank you so much! |
Hello. Thank you for such a useful gem!
I have a problem.
When I make a request in json format, the path parameter should contain a key named
format
, so the generated OpenAPI schema has a key namedformat
as a path parameter.So the generated OpenAPI schema has a
format
field in the path parameters list.Since I don't use this field as a variable in the actual path, the error occurs because there is no
format
in the URL when loaded by swagger-editor.Is there a problem with skipping the
format
in lib/rspec/openapi/schema_builder.rb:39 in the same way as theaction
andcontroller
?The text was updated successfully, but these errors were encountered: