Examples
Complete working examples showing Apiwork features with full generated output.
Each example includes:
- API definition, models, representations, contracts, and controllers
- Generated TypeScript types
- Generated Zod validators
- Generated OpenAPI export
- Introspection output
Available Examples
| Example | Description |
|---|---|
| Representations | Generate a complete contract from representation definitions |
| Manual Contracts | Define contracts manually without representations |
| Filtering and Sorting | Complex queries with string patterns, numeric ranges, and logical operators |
| Offset Pagination | Offset-based pagination with page number and page size query parameters |
| Cursor Pagination | Cursor-based pagination for navigating large datasets |
| Includes | Load associations on demand with include query parameters |
| Nested Saves | Create, update, and delete nested records in a single request |
| Write Modes | Control which fields are accepted on create vs update |
| Single Table Inheritance | Single Table Inheritance with automatic variant serialization and TypeScript union types |
| Polymorphic Associations | Comments that belong to different content types (posts, videos) |
| Union Types | Discriminated unions for polymorphic request and response shapes |
| Inline Types | Define typed JSON columns with object shapes, arrays, and nested structures |
| Type Imports | Share type definitions between contracts with import |
| Value Transforms | Transform values on input/output and handle nil/empty string conversion |
| Key and Path Formats | PascalCase keys with key_format :pascal and kebab-case paths with path_format :kebab |
| Validation Errors | ActiveRecord validation errors captured and presented in a unified format |
| Documentation | Document APIs with descriptions, examples, formats, and deprecation notices at every level |
| Documentation I18n | Translatable API documentation with built-in I18n support |
| Hash Responses | Expose plain hashes instead of ActiveRecord models |