Skip to content

Inconsistent create response status #110

Open
@wr0ngway

Description

@wr0ngway

Minor weirdness/inconsistency between a stock rails/oas app created using --api and not. For the --api variant it behaves as expected, but if I have a regular rails app with json api as part of regular html controllers, then the api docs setup a default 200 response code for create actions instead of 201 (:created), and oddly enough show a validation error schema for it (instead of for the 422). The --api variant has a 201 with a Post and a 422 with the validation schema

From a rails generate scaffold:

  def create
    @post = Post.new(post_params)

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: "Post was successfully created." }
        format.json { render :show, status: :created, location: @post }
      else
        format.html { render :new, status: :unprocessable_entity }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwontfixThis will not be worked on

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions