Skip to content

Add Sinatra integration (OpenapiFirst::Sinatra)#483

Draft
ahx wants to merge 1 commit into
mainfrom
sinatra-extension
Draft

Add Sinatra integration (OpenapiFirst::Sinatra)#483
ahx wants to merge 1 commit into
mainfrom
sinatra-extension

Conversation

@ahx
Copy link
Copy Markdown
Owner

@ahx ahx commented Jun 3, 2026

A Sinatra extension to define routes by referencing OpenAPI operations, so URLs and HTTP methods live only in the description:

    require 'openapi_first/sinatra'

    class PetsApp < Sinatra::Base
      register OpenapiFirst::Sinatra
      openapi 'openapi.yaml'

      operation(:create_pet) { |params| json create(params) }
    end

The HTTP method and path for each route come from the operationId. Request validation is called automatically for these operations.

Related to #365

@ahx ahx force-pushed the sinatra-extension branch from 1019124 to 640794f Compare June 3, 2026 13:14
A Sinatra extension to define routes by referencing OpenAPI operations,
so URLs and HTTP methods live only in the description:

    require 'openapi_first/sinatra'

    class PetsApi < Sinatra::Base
    register OpenapiFirst::Sinatra
    openapi 'openapi.yaml'

    operation :index_pets do |params|
    json index_pets(params[:filter])
    end
    end

The HTTP method and path for each route come from the operationId.
Request validation is called automatically for these operations.
@ahx ahx force-pushed the sinatra-extension branch from 640794f to de8bce8 Compare June 3, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant