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'
consumes 'application/json', 'application/xml'
parameter name: :blog, in: :body, schema: {
properties: {
data: {
type: :object,
items: {
properties: {
title: { type: :string },
content: { type: :string }
},
required: ['data','title']
}
},
},
}
response '201', 'blog created' do
let(:blog) { { title: 'foo', content: 'bar' } }
run_test!
end
response '422', 'invalid request' do
let(:blog) { { title: 'foo' } }
run_test!
end
end
end
end
I want create code swagger to json below:
data: {
type: articles,
attributes: {
title: { type: :string },
content: { type: :string }
},
}
How do I do this in rswag, is there any trick to leave in the json api specification?