mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
Reverted some files related to definitions changes
This commit is contained in:
parent
0020d71c90
commit
2b239ef0f3
@ -1,4 +1,4 @@
|
|||||||
OpenApi::Rswag::Api.configure do |c|
|
Rswag::Api.configure do |c|
|
||||||
|
|
||||||
# Specify a root folder where Swagger JSON files are located
|
# Specify a root folder where Swagger JSON files are located
|
||||||
# This is used by the Swagger middleware to serve requests for API descriptions
|
# This is used by the Swagger middleware to serve requests for API descriptions
|
||||||
|
|||||||
@ -61,7 +61,7 @@ module Rswag
|
|||||||
it 'locates files at the provided swagger_root' do
|
it 'locates files at the provided swagger_root' do
|
||||||
expect(response.length).to eql(3)
|
expect(response.length).to eql(3)
|
||||||
expect(response[1]).to include( 'Content-Type' => 'application/json')
|
expect(response[1]).to include( 'Content-Type' => 'application/json')
|
||||||
expect(response[2].join).to include('"swagger":"2.0"')
|
expect(response[2].join).to include('"openapi":"3.0.1"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20160218212104) do
|
ActiveRecord::Schema.define(version: 2016_02_18_212104) do
|
||||||
|
|
||||||
create_table "blogs", force: :cascade do |t|
|
create_table "blogs", force: :cascade do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'swagger_helper'
|
require 'swagger_helper'
|
||||||
|
|
||||||
RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||||
@ -12,24 +10,19 @@ RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
|||||||
operationId 'createBlog'
|
operationId 'createBlog'
|
||||||
consumes 'application/json'
|
consumes 'application/json'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
|
parameter name: :blog, in: :body, schema: { '$ref' => '#/definitions/blog' }
|
||||||
|
|
||||||
request_body_json schema: { '$ref' => '#/components/schemas/blog' },
|
let(:blog) { { title: 'foo', content: 'bar' } }
|
||||||
examples: :blog
|
|
||||||
|
|
||||||
request_body_text_plain
|
|
||||||
request_body_xml schema: { '$ref' => '#/components/schemas/blog' }
|
|
||||||
|
|
||||||
let(:blog) { { blog: { title: 'foo', content: 'bar' } } }
|
|
||||||
|
|
||||||
response '201', 'blog created' do
|
response '201', 'blog created' do
|
||||||
schema '$ref' => '#/components/schemas/blog'
|
# schema '$ref' => '#/definitions/blog'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
response '422', 'invalid request' do
|
response '422', 'invalid request' do
|
||||||
schema '$ref' => '#/components/schemas/errors_object'
|
schema '$ref' => '#/definitions/errors_object'
|
||||||
let(:blog) { { blog: { title: 'foo' } } }
|
|
||||||
|
|
||||||
|
let(:blog) { { title: 'foo' } }
|
||||||
run_test! do |response|
|
run_test! do |response|
|
||||||
expect(response.body).to include("can't be blank")
|
expect(response.body).to include("can't be blank")
|
||||||
end
|
end
|
||||||
@ -46,69 +39,18 @@ RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
|||||||
let(:keywords) { 'foo bar' }
|
let(:keywords) { 'foo bar' }
|
||||||
|
|
||||||
response '200', 'success' do
|
response '200', 'success' do
|
||||||
schema type: 'array', items: { '$ref' => '#/components/schemas/blog' }
|
schema type: 'array', items: { '$ref' => '#/definitions/blog' }
|
||||||
run_test!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
response '406', 'unsupported accept header' do
|
response '406', 'unsupported accept header' do
|
||||||
let(:Accept) { 'application/foo' }
|
let(:'Accept') { 'application/foo' }
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
path '/blogs/flexible' do
|
|
||||||
post 'Creates a blog flexible body' do
|
|
||||||
tags 'Blogs'
|
|
||||||
description 'Creates a flexible blog from provided data'
|
|
||||||
operationId 'createFlexibleBlog'
|
|
||||||
consumes 'application/json'
|
|
||||||
produces 'application/json'
|
|
||||||
|
|
||||||
request_body_json schema: {
|
|
||||||
:oneOf => [{'$ref' => '#/components/schemas/blog'},
|
|
||||||
{'$ref' => '#/components/schemas/flexible_blog'}]
|
|
||||||
},
|
|
||||||
examples: :flexible_blog
|
|
||||||
|
|
||||||
let(:flexible_blog) { { blog: { headline: 'my headline', text: 'my text' } } }
|
|
||||||
|
|
||||||
response '201', 'flexible blog created' do
|
|
||||||
schema :oneOf => [{'$ref' => '#/components/schemas/blog'},{'$ref' => '#/components/schemas/flexible_blog'}]
|
|
||||||
run_test!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
path '/blogs/alternate' do
|
|
||||||
post 'Creates a blog - different :examples in requestBody' do
|
|
||||||
tags 'Blogs'
|
|
||||||
description 'Creates a new blog from provided data'
|
|
||||||
operationId 'createAlternateBlog'
|
|
||||||
consumes 'application/json'
|
|
||||||
produces 'application/json'
|
|
||||||
|
|
||||||
# NOTE: the externalValue: http://... is valid 3.0 spec, but swagger-UI does NOT support it yet
|
|
||||||
# https://github.com/swagger-api/swagger-ui/issues/5433
|
|
||||||
request_body_json schema: { '$ref' => '#/components/schemas/blog' },
|
|
||||||
examples: [:blog, {name: :external_blog,
|
|
||||||
externalValue: 'http://api.sample.org/myjson_example'},
|
|
||||||
{name: :another_example,
|
|
||||||
'$ref' => '#/components/examples/flexible_blog_example'}]
|
|
||||||
|
|
||||||
let(:blog) { { blog: { title: 'alt title', content: 'alt bar' } } }
|
|
||||||
|
|
||||||
response '201', 'blog created' do
|
|
||||||
schema '$ref' => '#/components/schemas/blog'
|
|
||||||
run_test!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
path '/blogs/{id}' do
|
path '/blogs/{id}' do
|
||||||
|
parameter name: :id, in: :path, type: :string
|
||||||
|
|
||||||
let(:id) { blog.id }
|
let(:id) { blog.id }
|
||||||
let(:blog) { Blog.create(title: 'foo', content: 'bar', thumbnail: 'thumbnail.png') }
|
let(:blog) { Blog.create(title: 'foo', content: 'bar', thumbnail: 'thumbnail.png') }
|
||||||
@ -119,14 +61,12 @@ RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
|||||||
operationId 'getBlog'
|
operationId 'getBlog'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
|
|
||||||
parameter name: :id, in: :path, type: :string
|
|
||||||
|
|
||||||
response '200', 'blog found' do
|
response '200', 'blog found' do
|
||||||
header 'ETag', type: :string
|
header 'ETag', type: :string
|
||||||
header 'Last-Modified', type: :string
|
header 'Last-Modified', type: :string
|
||||||
header 'Cache-Control', type: :string
|
header 'Cache-Control', type: :string
|
||||||
|
|
||||||
schema '$ref' => '#/components/schemas/blog'
|
schema '$ref' => '#/definitions/blog'
|
||||||
|
|
||||||
examples 'application/json' => {
|
examples 'application/json' => {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -146,23 +86,21 @@ RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
path '/blogs/{id}/upload' do
|
path '/blogs/{id}/upload' do
|
||||||
|
parameter name: :id, in: :path, type: :string
|
||||||
|
|
||||||
let(:id) { blog.id }
|
let(:id) { blog.id }
|
||||||
let(:blog) { Blog.create(title: 'foo', content: 'bar') }
|
let(:blog) { Blog.create(title: 'foo', content: 'bar') }
|
||||||
|
|
||||||
put 'Uploads a blog thumbnail' do
|
put 'Uploads a blog thumbnail' do
|
||||||
parameter name: :id, in: :path, type: :string
|
|
||||||
|
|
||||||
tags 'Blogs'
|
tags 'Blogs'
|
||||||
description 'Upload a thumbnail for specific blog by id'
|
description 'Upload a thumbnail for specific blog by id'
|
||||||
operationId 'uploadThumbnailBlog'
|
operationId 'uploadThumbnailBlog'
|
||||||
consumes 'multipart/form-data'
|
consumes 'multipart/form-data'
|
||||||
|
parameter name: :file, :in => :formData, :type => :file, required: true
|
||||||
request_body_multipart schema: {properties: {:orderId => { type: :integer }, file: { type: :string, format: :binary }} }
|
|
||||||
|
|
||||||
response '200', 'blog updated' do
|
response '200', 'blog updated' do
|
||||||
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/thumbnail.png')) }
|
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join("spec/fixtures/thumbnail.png")) }
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
170
test-app/spec/integration/new_blogs_spec.rb
Normal file
170
test-app/spec/integration/new_blogs_spec.rb
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
# # frozen_string_literal: true
|
||||||
|
|
||||||
|
# require 'swagger_helper'
|
||||||
|
|
||||||
|
# RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||||
|
# let(:api_key) { 'fake_key' }
|
||||||
|
|
||||||
|
# path '/blogs' do
|
||||||
|
# post 'Creates a blog' do
|
||||||
|
# tags 'Blogs'
|
||||||
|
# description 'Creates a new blog from provided data'
|
||||||
|
# operationId 'createBlog'
|
||||||
|
# consumes 'application/json'
|
||||||
|
# produces 'application/json'
|
||||||
|
|
||||||
|
# request_body_json schema: { '$ref' => '#/components/schemas/blog' },
|
||||||
|
# examples: :blog
|
||||||
|
|
||||||
|
# request_body_text_plain
|
||||||
|
# request_body_xml schema: { '$ref' => '#/components/schemas/blog' }
|
||||||
|
|
||||||
|
# let(:blog) { { blog: { title: 'foo', content: 'bar' } } }
|
||||||
|
|
||||||
|
# response '201', 'blog created' do
|
||||||
|
# schema '$ref' => '#/components/schemas/blog'
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
|
||||||
|
# response '422', 'invalid request' do
|
||||||
|
# schema '$ref' => '#/components/schemas/errors_object'
|
||||||
|
# let(:blog) { { blog: { title: 'foo' } } }
|
||||||
|
|
||||||
|
# run_test! do |response|
|
||||||
|
# expect(response.body).to include("can't be blank")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
# get 'Searches blogs' do
|
||||||
|
# tags 'Blogs'
|
||||||
|
# description 'Searches blogs by keywords'
|
||||||
|
# operationId 'searchBlogs'
|
||||||
|
# produces 'application/json'
|
||||||
|
# parameter name: :keywords, in: :query, type: 'string'
|
||||||
|
|
||||||
|
# let(:keywords) { 'foo bar' }
|
||||||
|
|
||||||
|
# response '200', 'success' do
|
||||||
|
# schema type: 'array', items: { '$ref' => '#/components/schemas/blog' }
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
|
||||||
|
# response '406', 'unsupported accept header' do
|
||||||
|
# let(:Accept) { 'application/foo' }
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
# path '/blogs/flexible' do
|
||||||
|
# post 'Creates a blog flexible body' do
|
||||||
|
# tags 'Blogs'
|
||||||
|
# description 'Creates a flexible blog from provided data'
|
||||||
|
# operationId 'createFlexibleBlog'
|
||||||
|
# consumes 'application/json'
|
||||||
|
# produces 'application/json'
|
||||||
|
|
||||||
|
# request_body_json schema: {
|
||||||
|
# :oneOf => [{'$ref' => '#/components/schemas/blog'},
|
||||||
|
# {'$ref' => '#/components/schemas/flexible_blog'}]
|
||||||
|
# },
|
||||||
|
# examples: :flexible_blog
|
||||||
|
|
||||||
|
# let(:flexible_blog) { { blog: { headline: 'my headline', text: 'my text' } } }
|
||||||
|
|
||||||
|
# response '201', 'flexible blog created' do
|
||||||
|
# schema :oneOf => [{'$ref' => '#/components/schemas/blog'},{'$ref' => '#/components/schemas/flexible_blog'}]
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
# path '/blogs/alternate' do
|
||||||
|
# post 'Creates a blog - different :examples in requestBody' do
|
||||||
|
# tags 'Blogs'
|
||||||
|
# description 'Creates a new blog from provided data'
|
||||||
|
# operationId 'createAlternateBlog'
|
||||||
|
# consumes 'application/json'
|
||||||
|
# produces 'application/json'
|
||||||
|
|
||||||
|
# # NOTE: the externalValue: http://... is valid 3.0 spec, but swagger-UI does NOT support it yet
|
||||||
|
# # https://github.com/swagger-api/swagger-ui/issues/5433
|
||||||
|
# request_body_json schema: { '$ref' => '#/components/schemas/blog' },
|
||||||
|
# examples: [:blog, {name: :external_blog,
|
||||||
|
# externalValue: 'http://api.sample.org/myjson_example'},
|
||||||
|
# {name: :another_example,
|
||||||
|
# '$ref' => '#/components/examples/flexible_blog_example'}]
|
||||||
|
|
||||||
|
# let(:blog) { { blog: { title: 'alt title', content: 'alt bar' } } }
|
||||||
|
|
||||||
|
# response '201', 'blog created' do
|
||||||
|
# schema '$ref' => '#/components/schemas/blog'
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# path '/blogs/{id}' do
|
||||||
|
|
||||||
|
|
||||||
|
# let(:id) { blog.id }
|
||||||
|
# let(:blog) { Blog.create(title: 'foo', content: 'bar', thumbnail: 'thumbnail.png') }
|
||||||
|
|
||||||
|
# get 'Retrieves a blog' do
|
||||||
|
# tags 'Blogs'
|
||||||
|
# description 'Retrieves a specific blog by id'
|
||||||
|
# operationId 'getBlog'
|
||||||
|
# produces 'application/json'
|
||||||
|
|
||||||
|
# parameter name: :id, in: :path, type: :string
|
||||||
|
|
||||||
|
# response '200', 'blog found' do
|
||||||
|
# header 'ETag', type: :string
|
||||||
|
# header 'Last-Modified', type: :string
|
||||||
|
# header 'Cache-Control', type: :string
|
||||||
|
|
||||||
|
# schema '$ref' => '#/components/schemas/blog'
|
||||||
|
|
||||||
|
# examples 'application/json' => {
|
||||||
|
# id: 1,
|
||||||
|
# title: 'Hello world!',
|
||||||
|
# content: 'Hello world and hello universe. Thank you all very much!!!',
|
||||||
|
# thumbnail: 'thumbnail.png'
|
||||||
|
# }
|
||||||
|
|
||||||
|
# let(:id) { blog.id }
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
|
||||||
|
# response '404', 'blog not found' do
|
||||||
|
# let(:id) { 'invalid' }
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
# path '/blogs/{id}/upload' do
|
||||||
|
# let(:id) { blog.id }
|
||||||
|
# let(:blog) { Blog.create(title: 'foo', content: 'bar') }
|
||||||
|
|
||||||
|
# put 'Uploads a blog thumbnail' do
|
||||||
|
# parameter name: :id, in: :path, type: :string
|
||||||
|
|
||||||
|
# tags 'Blogs'
|
||||||
|
# description 'Upload a thumbnail for specific blog by id'
|
||||||
|
# operationId 'uploadThumbnailBlog'
|
||||||
|
# consumes 'multipart/form-data'
|
||||||
|
|
||||||
|
# request_body_multipart schema: {properties: {:orderId => { type: :integer }, file: { type: :string, format: :binary }} }
|
||||||
|
|
||||||
|
# response '200', 'blog updated' do
|
||||||
|
# let(:file) { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/thumbnail.png')) }
|
||||||
|
# run_test!
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
@ -32,13 +32,11 @@ RSpec.configure do |config|
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
definitions: {
|
||||||
components: {
|
|
||||||
schemas: {
|
|
||||||
errors_object: {
|
errors_object: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
errors: { '$ref' => '#/components/schemas/errors_map' }
|
errors: { '$ref' => '#/definitions/errors_map' }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
errors_map: {
|
errors_map: {
|
||||||
@ -53,36 +51,15 @@ RSpec.configure do |config|
|
|||||||
properties: {
|
properties: {
|
||||||
id: { type: 'integer' },
|
id: { type: 'integer' },
|
||||||
title: { type: 'string' },
|
title: { type: 'string' },
|
||||||
content: { type: 'string', nullable: true },
|
content: { type: 'string', 'x-nullable': true },
|
||||||
thumbnail: { type: 'string', nullable: true }
|
thumbnail: { type: 'string'}
|
||||||
},
|
},
|
||||||
required: %w[id title]
|
required: [ 'id', 'title', 'content', 'thumbnail' ]
|
||||||
},
|
|
||||||
flexible_blog: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
id: { type: 'integer' },
|
|
||||||
headline: { type: 'string' },
|
|
||||||
text: { type: 'string', nullable: true },
|
|
||||||
thumbnail: { type: 'string', nullable:true }
|
|
||||||
},
|
|
||||||
required: %w[id headline]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
examples: {
|
securityDefinitions: {
|
||||||
flexible_blog_example: {
|
|
||||||
summary: 'Sample example of a flexible blog',
|
|
||||||
value: {
|
|
||||||
id: 1,
|
|
||||||
headline: 'This is a headline',
|
|
||||||
text: 'Some sample text'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
securitySchemes: {
|
|
||||||
basic_auth: {
|
basic_auth: {
|
||||||
type: :http,
|
type: :basic
|
||||||
scheme: :basic
|
|
||||||
},
|
},
|
||||||
api_key: {
|
api_key: {
|
||||||
type: :apiKey,
|
type: :apiKey,
|
||||||
@ -92,5 +69,4 @@ RSpec.configure do |config|
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -88,71 +88,29 @@
|
|||||||
],
|
],
|
||||||
"description": "Creates a new blog from provided data",
|
"description": "Creates a new blog from provided data",
|
||||||
"operationId": "createBlog",
|
"operationId": "createBlog",
|
||||||
"requestBody": {
|
"consumes": [
|
||||||
"required": true,
|
"application/json"
|
||||||
"content": {
|
],
|
||||||
"application/json": {
|
"produces": [
|
||||||
"examples": {
|
"application/json"
|
||||||
"blog": {
|
],
|
||||||
"value": {
|
|
||||||
"blog": {
|
|
||||||
"title": "foo",
|
|
||||||
"content": "bar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test/plain": {
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"application/xml": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "blog",
|
||||||
|
"in": "body",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/blog"
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"201": {
|
"201": {
|
||||||
"description": "blog created",
|
"description": "blog created"
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"example": {
|
|
||||||
"id": 1,
|
|
||||||
"title": "foo",
|
|
||||||
"content": "bar",
|
|
||||||
"thumbnail": null
|
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"422": {
|
"422": {
|
||||||
"description": "invalid request",
|
"description": "invalid request",
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"example": {
|
|
||||||
"errors": {
|
|
||||||
"content": [
|
|
||||||
"can't be blank"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/errors_object"
|
"$ref": "#/definitions/errors_object"
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,158 +122,32 @@
|
|||||||
],
|
],
|
||||||
"description": "Searches blogs by keywords",
|
"description": "Searches blogs by keywords",
|
||||||
"operationId": "searchBlogs",
|
"operationId": "searchBlogs",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "keywords",
|
"name": "keywords",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
|
||||||
"description": "success",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"406": {
|
"406": {
|
||||||
"description": "unsupported accept header"
|
"description": "unsupported accept header"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/blogs/flexible": {
|
|
||||||
"post": {
|
|
||||||
"summary": "Creates a blog flexible body",
|
|
||||||
"tags": [
|
|
||||||
"Blogs"
|
|
||||||
],
|
|
||||||
"description": "Creates a flexible blog from provided data",
|
|
||||||
"operationId": "createFlexibleBlog",
|
|
||||||
"requestBody": {
|
|
||||||
"required": true,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"examples": {
|
|
||||||
"flexible_blog": {
|
|
||||||
"value": {
|
|
||||||
"blog": {
|
|
||||||
"headline": "my headline",
|
|
||||||
"text": "my text"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/flexible_blog"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"parameters": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"201": {
|
|
||||||
"description": "flexible blog created",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"example": {
|
|
||||||
"id": 1,
|
|
||||||
"title": "my headline",
|
|
||||||
"content": "my text",
|
|
||||||
"thumbnail": null
|
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/flexible_blog"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/blogs/alternate": {
|
|
||||||
"post": {
|
|
||||||
"summary": "Creates a blog - different :examples in requestBody",
|
|
||||||
"tags": [
|
|
||||||
"Blogs"
|
|
||||||
],
|
|
||||||
"description": "Creates a new blog from provided data",
|
|
||||||
"operationId": "createAlternateBlog",
|
|
||||||
"requestBody": {
|
|
||||||
"required": true,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"examples": {
|
|
||||||
"blog": {
|
|
||||||
"value": {
|
|
||||||
"blog": {
|
|
||||||
"title": "alt title",
|
|
||||||
"content": "alt bar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"external_blog": {
|
|
||||||
"externalValue": "http://api.sample.org/myjson_example"
|
|
||||||
},
|
|
||||||
"another_example": {
|
|
||||||
"$ref": "#/components/examples/flexible_blog_example"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"parameters": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"201": {
|
|
||||||
"description": "blog created",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"example": {
|
|
||||||
"id": 1,
|
|
||||||
"title": "alt title",
|
|
||||||
"content": "alt bar",
|
|
||||||
"thumbnail": null
|
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/blogs/{id}": {
|
"/blogs/{id}": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Retrieves a blog",
|
"summary": "Retrieves a blog",
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -323,47 +155,32 @@
|
|||||||
],
|
],
|
||||||
"description": "Retrieves a specific blog by id",
|
"description": "Retrieves a specific blog by id",
|
||||||
"operationId": "getBlog",
|
"operationId": "getBlog",
|
||||||
"parameters": [
|
"produces": [
|
||||||
{
|
"application/json"
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "blog found",
|
"description": "blog found",
|
||||||
"headers": {
|
"headers": {
|
||||||
"ETag": {
|
"ETag": {
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"Last-Modified": {
|
"Last-Modified": {
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"Cache-Control": {
|
"Cache-Control": {
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"content": {
|
"schema": {
|
||||||
|
"$ref": "#/definitions/blog"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"example": {
|
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"title": "Hello world!",
|
"title": "Hello world!",
|
||||||
"content": "Hello world and hello universe. Thank you all very much!!!",
|
"content": "Hello world and hello universe. Thank you all very much!!!",
|
||||||
"thumbnail": "thumbnail.png"
|
"thumbnail": "thumbnail.png"
|
||||||
},
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/blog"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -374,40 +191,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/blogs/{id}/upload": {
|
"/blogs/{id}/upload": {
|
||||||
"put": {
|
|
||||||
"summary": "Uploads a blog thumbnail",
|
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true,
|
"type": "string",
|
||||||
"schema": {
|
"required": true
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"put": {
|
||||||
|
"summary": "Uploads a blog thumbnail",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Blogs"
|
"Blogs"
|
||||||
],
|
],
|
||||||
"description": "Upload a thumbnail for specific blog by id",
|
"description": "Upload a thumbnail for specific blog by id",
|
||||||
"operationId": "uploadThumbnailBlog",
|
"operationId": "uploadThumbnailBlog",
|
||||||
"requestBody": {
|
"consumes": [
|
||||||
"content": {
|
"multipart/form-data"
|
||||||
"multipart/form-data": {
|
],
|
||||||
"schema": {
|
"parameters": [
|
||||||
"properties": {
|
{
|
||||||
"orderId": {
|
"name": "file",
|
||||||
"type": "integer"
|
"in": "formData",
|
||||||
},
|
"type": "file",
|
||||||
"file": {
|
"required": true
|
||||||
"type": "string",
|
|
||||||
"format": "binary"
|
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "blog updated"
|
"description": "blog updated"
|
||||||
@ -426,13 +235,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"components": {
|
"definitions": {
|
||||||
"schemas": {
|
|
||||||
"errors_object": {
|
"errors_object": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"errors": {
|
"errors": {
|
||||||
"$ref": "#/components/schemas/errors_map"
|
"$ref": "#/definitions/errors_map"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -456,56 +264,23 @@
|
|||||||
},
|
},
|
||||||
"content": {
|
"content": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"nullable": true
|
"x-nullable": true
|
||||||
},
|
},
|
||||||
"thumbnail": {
|
"thumbnail": {
|
||||||
"type": "string",
|
|
||||||
"nullable": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"title"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"flexible_blog": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"headline": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
|
||||||
"text": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true
|
|
||||||
},
|
|
||||||
"thumbnail": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
"headline"
|
"title",
|
||||||
|
"content",
|
||||||
|
"thumbnail"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"examples": {
|
"securityDefinitions": {
|
||||||
"flexible_blog_example": {
|
|
||||||
"summary": "Sample example of a flexible blog",
|
|
||||||
"value": {
|
|
||||||
"id": 1,
|
|
||||||
"headline": "This is a headline",
|
|
||||||
"text": "Some sample text"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"securitySchemes": {
|
|
||||||
"basic_auth": {
|
"basic_auth": {
|
||||||
"type": "http",
|
"type": "basic"
|
||||||
"scheme": "basic"
|
|
||||||
},
|
},
|
||||||
"api_key": {
|
"api_key": {
|
||||||
"type": "apiKey",
|
"type": "apiKey",
|
||||||
@ -513,5 +288,4 @@
|
|||||||
"in": "query"
|
"in": "query"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user