28_introduce_rswag #35

Merged
philipp merged 46 commits from 28_introduce_rswag into develop 2023-01-05 13:45:47 +01:00
3 changed files with 86 additions and 1 deletions
Showing only changes of commit 3b7eae694a - Show all commits

View file

@ -0,0 +1,40 @@
require 'swagger_helper'
describe 'Article Categories', type: :request do
include ApiHelper
path '/article_categories' do
get 'article categories' do
tags 'Category'
produces 'application/json'
parameter name: :page, in: :query, schema: { '$ref' => '#/components/schemas/page' }
parameter name: :per_page, in: :query, schema: { '$ref' => '#/components/schemas/per_page' }
let(:api_scopes) { ['orders:read'] }
let!(:order_article) { create(:order, article_count: 1).order_articles.first }
let!(:stock_article) { create(:stock_article) }
let!(:stock_order_article) { create(:stock_order, article_ids: [stock_article.id]).order_articles.first }
response '200', 'success' do
schema type: :object, properties: {
article_categories: {
type: :array,
items: {
'$ref': '#/components/schemas/ArticleCategory'
}
},
meta: {
'$ref': '#/components/schemas/Meta'
}
}
let(:page) { 0 }
let(:per_page) { 20 }
run_test!
end
it_handles_invalid_token_and_scope
end
end
end

View file

@ -7,7 +7,6 @@ describe 'Navigation', type: :request do
get 'navigation' do get 'navigation' do
tags 'General' tags 'General'
produces 'application/json' produces 'application/json'
let(:api_scopes) { ['config:user'] }
response '200', 'success' do response '200', 'success' do
schema type: :object, properties: { schema type: :object, properties: {

View file

@ -24,6 +24,52 @@ RSpec.configure do |config|
paths: {}, paths: {},
components: { components: {
schemas: { schemas: {
page: {
type: :integer,
description: 'page number',
minimum: 0,
default: 0
},
per_page: {
type: :integer,
description: 'items per page',
minimum: 0,
default: 20
},
ArticleCategory: {
type: :object,
properties: {
id: {
type: :integer
},
name: {
type: :string
}
},
required: %w[id name]
},
Meta: {
type: :object,
properties: {
page: {
type: :integer,
description: 'page number of the returned collection'
},
per_page: {
type: :integer,
description: 'number of items per page'
},
total_pages: {
type: :integer,
description: 'total number of pages'
},
total_count: {
type: :integer,
description: 'total number of items in the collection'
},
required: %w[page per_page total_pages total_count]
}
},
Navigation: { Navigation: {
type: :array, type: :array,
items: { items: {