Module: AnotherApi::OpenAPI::CommonSchemas
- Defined in:
- lib/another_api/openapi/common_schemas.rb
Overview
Default OpenAPI schema components: parameters, pagination metadata, error responses, and security schemes. Each method returns a fresh hash so callers can mutate without surprising side effects. Configuration references these as defaults; users can override any of them via AnotherApi::OpenAPI.configure.
Class Method Summary collapse
- .default_error_response ⇒ Object
- .default_pagination_metadata ⇒ Object
- .default_parameters ⇒ Object
- .default_security_schemes ⇒ Object
Class Method Details
.default_error_response ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/another_api/openapi/common_schemas.rb', line 42 def default_error_response {"application/json" => { schema: { type: "object", properties: { success: {type: "boolean", enum: [false]}, error_type: {type: "string"}, error_message: {type: "string"} } } }} end |
.default_pagination_metadata ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/another_api/openapi/common_schemas.rb', line 25 def { type: "object", properties: { offset: {type: "integer"}, count: {type: "integer", description: "Records in current page"}, total_count: {type: "integer", description: "Total records matching query"}, total_pages: {type: "integer"}, has_more: {type: "boolean"}, request_id: {type: "string", format: "uuid"}, request_started_at: {type: "string", format: "date-time"}, request_ended_at: {type: "string", format: "date-time"}, next_poll_at: {type: "string", format: "date-time"} } } end |
.default_parameters ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/another_api/openapi/common_schemas.rb', line 13 def default_parameters { page: {name: "page", in: "query", required: false, schema: {type: "integer", minimum: 1, default: 1}, description: "Page number"}, page_size: {name: "page_size", in: "query", required: false, schema: {type: "integer", minimum: 1, maximum: 200, default: 20}, description: "Records per page (max 200)"}, variant: {name: "variant", in: "query", required: false, schema: {type: "string", enum: %w[id_only minimal full]}, description: "Response detail level"}, filter: {name: "filter", in: "query", required: false, schema: {type: "string"}, description: "Filter expression. Values must be URI-encoded."}, sort: {name: "sort", in: "query", required: false, schema: {type: "string"}, description: "Sort expression. Format: field:asc or field:desc. Multiple fields separated by semicolons."}, deleted: {name: "deleted", in: "query", required: false, schema: {type: "string", enum: %w[exclude include only], default: "exclude"}, description: "Include soft-deleted records"}, active: {name: "active", in: "query", required: false, schema: {type: "string", enum: %w[only include exclude], default: "only"}, description: "Filter by active/inactive status"} } end |
.default_security_schemes ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/another_api/openapi/common_schemas.rb', line 55 def default_security_schemes { bearerAuth: { type: "http", scheme: "bearer", description: "API key token. Obtain from your account settings." } } end |