Skip to content

Instantly share code, notes, and snippets.

@ota42y
Last active June 2, 2020 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ota42y/0870100c03444d39d78107a23de9f171 to your computer and use it in GitHub Desktop.
Save ota42y/0870100c03444d39d78107a23de9f171 to your computer and use it in GitHub Desktop.
schema_path = Rails.root.join("config/openapi.yaml").to_s
config.middleware.use Committee::Middleware::RequestValidation,
schema_path: schema_path,
params_key: 'action_dispatch.request.request_parameters'
openapi: 3.0.0
info:
title: api-test
version: '1.0'
servers:
- url: 'http://localhost:3000'
paths:
/users:
post:
parameters:
- in: query
name: page
schema:
type: integer
requestBody:
content:
application/json:
schema:
type: object
required:
- registered_at
properties:
age:
type: integer
registered_at:
type: string
format: "date-time"
responses:
'204':
description: No Content
content:
application/json:
schema:
type: object
class UsersController < ApplicationController
skip_before_action :verify_authenticity_token
def create
binding.pry
registered_at = params[:registered_at]
raise "error" unless registered_at < Time.now
user = ["debug user1"] # do something
head :ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment