diff --git a/spec/requests/api/article_categories_spec.rb b/spec/requests/api/article_categories_spec.rb index afdcfae2..68467241 100644 --- a/spec/requests/api/article_categories_spec.rb +++ b/spec/requests/api/article_categories_spec.rb @@ -9,8 +9,6 @@ describe 'Article Categories', type: :request do produces 'application/json' parameter name: "per_page", in: :query, type: :integer, required: false parameter name: "page", in: :query, type: :integer, required: false - let(:page) { 1 } - let(:per_page) { 10 } 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 } @@ -46,36 +44,11 @@ describe 'Article Categories', type: :request do } } } - let(:id) { ArticleCategory.create(name: 'dairy').id } - run_test! - end - - response '401', 'not logged in' do - schema type: :object, properties: { - article_categories: { - type: :array, - items: { - '$ref': '#/components/schemas/ArticleCategory' - } - } - } - let(:Authorization) { 'abc' } - let(:id) { ArticleCategory.create(name: 'dairy').id } - run_test! - end - - response '404', 'article category not found' do - schema type: :object, properties: { - article_categories: { - type: :array, - items: { - '$ref': '#/components/schemas/ArticleCategory' - } - } - } - let(:id) { 'invalid' } + let(:id) { create(:article_category, name: 'dairy').id } run_test! end + it_handles_invalid_token_with_id(:article_category) + it_cannot_find_object end end end diff --git a/spec/support/api_helper.rb b/spec/support/api_helper.rb index 176e9e21..b0831ed9 100644 --- a/spec/support/api_helper.rb +++ b/spec/support/api_helper.rb @@ -30,7 +30,7 @@ module ApiHelper end end - def self.it_handles_invalid_scope(description="missing scope") + def self.it_handles_invalid_scope(description = "missing scope") context 'with invalid scope' do let(:api_scopes) { ['none'] } @@ -45,6 +45,7 @@ module ApiHelper context 'with invalid scope' do let(:api_scopes) { ['none'] } let(:id) { create(class_sym).id } + response 403, description do schema '$ref' => '#/components/schemas/Error403' run_test! @@ -52,18 +53,12 @@ module ApiHelper end end - def self.it_cannot_find_object(description="not found") - # 404 - response '404', description do - schema type: :object, properties: { - group_order_article: { - type: :object, - items: { - '$ref': '#/components/schemas/GroupOrderArticle' - } - } - } - let(:id) { 'invalid' } + def self.it_cannot_find_object(description = "not found") + let(:id) { 'invalid' } + + + response 404, description do + schema '$ref' => '#/components/schemas/Error404' run_test! end end diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml deleted file mode 100644 index 5fe3a5a3..00000000 --- a/swagger/v1/swagger.yaml +++ /dev/null @@ -1,169 +0,0 @@ ---- -openapi: 3.0.1 -info: - title: API V1 - version: v1 -paths: - "/user": - get: - summary: info about the currently logged-in user - tags: - - User - responses: - '200': - description: success - content: - application/json: - schema: - type: object - properties: - user: - type: object - properties: - id: - type: integer - name: - type: string - description: full name - email: - type: string - description: email address - locale: - type: string - description: language code - required: - - id - - name - - email - '401': - description: not logged-in - content: - application/json: - schema: - "$ref": "#/components/schemas/Error401" - '403': - description: missing scope - content: - application/json: - schema: - "$ref": "#/components/schemas/Error403" - "/user/financial_overview": - get: - summary: financial summary about the currently logged-in user - tags: - - User - - FinancialTransaction - responses: - '200': - description: success - content: - application/json: - schema: - type: object - properties: - account_balance: - type: number - description: booked accout balance of ordergroup - available_funds: - type: number - description: fund available to order articles - financial_transaction_class_sums: - type: object - properties: - id: - type: integer - description: id of the financial transaction class - name: - type: string - description: name of the financial transaction class - amount: - type: number - description: sum of the amounts belonging to the financial - transaction class - required: - - id - - name - - amount - required: - - account_balance - - available_funds - - financial_transaction_class_sums - '401': - description: not logged-in - content: - application/json: - schema: - "$ref": "#/components/schemas/Error401" - '403': - description: missing scope - content: - application/json: - schema: - "$ref": "#/components/schemas/Error403" -components: - schemas: - Error: - type: object - properties: - error: - type: string - description: error code - error_description: - type: string - description: human-readable error message (localized) - Error401: - type: object - properties: - error: - type: string - description: "unauthorized" - error_description: - "$ref": "#/components/schemas/Error/properties/error_description" - Error403: - type: object - properties: - error: - type: string - description: "forbidden or invalid_scope" - error_description: - "$ref": "#/components/schemas/Error/properties/error_description" - Error404: - type: object - properties: - error: - type: string - description: "not_found" - error_description: - "$ref": "#/components/schemas/Error/properties/error_description" - Error422: - type: object - properties: - error: - type: string - description: unprocessable entity - error_description: - "$ref": "#/components/schemas/Error/properties/error_description" - securitySchemes: - oauth2: - type: oauth2 - flows: - implicit: - authorizationUrl: http://localhost:3000/f/oauth/authorize - scopes: - config:user: reading Foodsoft configuration for regular users - config:read: reading Foodsoft configuration values - config:write: reading and updating Foodsoft configuration values - finance:user: accessing your own financial transactions - finance:read: reading all financial transactions - finance:write: reading and creating financial transactions - user:read: reading your own user profile - user:write: reading and updating your own user profile - offline_access: retain access after user has logged out -servers: -- url: http://{defaultHost}/f/api/v1 - variables: - defaultHost: - default: localhost:3000 -security: -- oauth2: - - user:read