mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Merge branch 'openapi/master' into openapi/merge
This commit is contained in:
@@ -8,6 +8,25 @@ class BlogsController < ApplicationController
|
||||
respond_with @blog
|
||||
end
|
||||
|
||||
# POST /blogs/flexible
|
||||
def flexible_create
|
||||
|
||||
# contrived example to play around with new anyOf and oneOf
|
||||
# request body definition for 3.0
|
||||
blog_params = params.require(:blog).permit(:title, :content, :headline, :text)
|
||||
|
||||
@blog = Blog.create(blog_params)
|
||||
respond_with @blog
|
||||
end
|
||||
|
||||
# POST /blogs/alternate
|
||||
def alternate_create
|
||||
|
||||
# contrived example to show different :examples in the requestBody section
|
||||
@blog = Blog.create(params.require(:blog).permit(:title, :content))
|
||||
respond_with @blog
|
||||
end
|
||||
|
||||
# Put /blogs/1
|
||||
def upload
|
||||
@blog = Blog.find_by_id(params[:id])
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Blog < ActiveRecord::Base
|
||||
validates :content, presence: true
|
||||
|
||||
def as_json(options)
|
||||
alias_attribute :headline, :title
|
||||
alias_attribute :text, :content
|
||||
|
||||
def as_json(_options)
|
||||
{
|
||||
id: id,
|
||||
title: title,
|
||||
content: nil,
|
||||
content: content,
|
||||
thumbnail: thumbnail
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user