28_introduce_rswag #35
2 changed files with 47 additions and 1 deletions
25
spec/requests/api/navigation_spec.rb
Normal file
25
spec/requests/api/navigation_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
require 'swagger_helper'
|
||||||
|
|
||||||
|
describe 'Navigation API', type: :request do
|
||||||
|
include ApiHelper
|
||||||
|
|
||||||
|
path '/navigation' do
|
||||||
|
get 'navigation' do
|
||||||
|
tags 'General'
|
||||||
|
produces 'application/json'
|
||||||
|
let(:api_scopes) { ['config:user'] }
|
||||||
|
|
||||||
|
response '200', 'success' do
|
||||||
|
schema type: :object, properties: {
|
||||||
|
navigation: {
|
||||||
|
'$ref' => '#/components/schemas/Navigation'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run_test!
|
||||||
|
end
|
||||||
|
|
||||||
|
it_handles_invalid_token
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -16,7 +16,7 @@ RSpec.configure do |config|
|
||||||
# the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
|
# the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
|
||||||
config.swagger_docs = {
|
config.swagger_docs = {
|
||||||
'v1/swagger.yaml' => {
|
'v1/swagger.yaml' => {
|
||||||
openapi: '3.0.1',
|
openapi: '3.0.3',
|
||||||
info: {
|
info: {
|
||||||
title: 'API V1',
|
title: 'API V1',
|
||||||
version: 'v1'
|
version: 'v1'
|
||||||
|
@ -24,6 +24,27 @@ RSpec.configure do |config|
|
||||||
paths: {},
|
paths: {},
|
||||||
components: {
|
components: {
|
||||||
schemas: {
|
schemas: {
|
||||||
|
Navigation: {
|
||||||
|
type: :array,
|
||||||
|
items: {
|
||||||
|
type: :object,
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: :string,
|
||||||
|
description: 'title'
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
type: :string,
|
||||||
|
description: 'link'
|
||||||
|
},
|
||||||
|
items: {
|
||||||
|
'$ref': "#/components/schemas/Navigation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: ['name'],
|
||||||
|
minProperties: 2 # name+url or name+items
|
||||||
|
}
|
||||||
|
},
|
||||||
Error: {
|
Error: {
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: {
|
properties: {
|
||||||
|
|
Loading…
Reference in a new issue