[BUG] Unable to generate top-level tags key
dollerbill opened this issue · comments
Billy Cropley commented
Describe the bug
OAS 3.1.0 supports a top-level tags object that allows optional "description" fields, but I've been unable to find a way to produce this when generating yaml from Rswag
Steps to Test or Reproduce
Ideally, this would work when providing the tags keyword either in a path block or top-level describe block for the api
path '/pets' do
tags name: 'pet', description: 'Everything about your Pets'
or
describe 'Pets API' do
tags name: 'pet', description: 'Everything about your Pets'
both of these result in a NoMethodError:
Failure/Error: tags name: 'pet', description: 'Everything about your Pets'
NoMethodError:
undefined method `[]=' for nil:NilClass
metadata[:operation][attr_name] = value
^^^^^^^^^^^^^
Expected behavior
Output should be similar to:
info:
title: "Pet Sample"
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
paths:
"/pets":
Additional context
Sample JSON showing tags object
Dependency versions
The version of are you using for:
- Rswag: 2.7.0
- RSpec: 3.1.0
- Rails: 6.1.7.3
- Ruby: 3.1.0
(briefly tested with Rswag 2.10.1, issue remains)
Relates to which version of OAS (OpenAPI Specification)
- OAS2
- OAS3
- OAS3.1
Billy Cropley commented
for the time being I'm getting around this by manually adding them using a callback in my swagger_helper, a simplified example:
config.after do
doc_tags = [{name: 'Pet', description: 'Everything about your pets'}]
swagger_docs = config.instance_variable_get('@swagger_docs')
swagger_docs.each do |_path, doc|
doc[:tags] = doc_tags
end
end