mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 23:15:46 +08:00
ee7809e8a8
From the openapi spec: https://spec.openapis.org/oas/latest.html#fixed-fields-7 each endpoint needs to have an `operationId`: > Unique string used to identify the operation. The id MUST be unique > among all operations described in the API. The operationId value is > case-sensitive. Tools and libraries MAY use the operationId to uniquely > identify an operation, therefore, it is RECOMMENDED to follow common > programming naming conventions. Running the linter on our openapi.json file with this command: `npx @redocly/openapi-cli lint openapi.json` produced the following warning on all of our endpoints: > Operation object should contain `operationId` field This commit resolves these warnings by adding an operationId field to each endpoint.
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
require 'swagger_helper'
|
|
|
|
describe 'uploads' do
|
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
let(:logo_file) { file_from_fixtures("logo.png") }
|
|
let(:logo) { Rack::Test::UploadedFile.new(logo_file) }
|
|
|
|
before do
|
|
Jobs.run_immediately!
|
|
sign_in(admin)
|
|
end
|
|
|
|
path '/uploads.json' do
|
|
post 'Creates an upload' do
|
|
tags 'Uploads'
|
|
operationId 'createUpload'
|
|
consumes 'multipart/form-data'
|
|
|
|
expected_request_schema = load_spec_schema('upload_create_request')
|
|
parameter name: :params, in: :body, schema: expected_request_schema
|
|
|
|
let(:params) { {
|
|
type: 'avatar',
|
|
user_id: admin.id,
|
|
synchronous: true,
|
|
file: logo
|
|
} }
|
|
|
|
produces 'application/json'
|
|
response '200', 'file uploaded' do
|
|
expected_response_schema = load_spec_schema('upload_create_response')
|
|
schema(expected_response_schema)
|
|
|
|
# Skipping this test for now until https://github.com/rswag/rswag/issues/348
|
|
# is resolved. This still allows the docs to be generated for this endpoint though.
|
|
xit
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|