goldspecdigital/oooas
Dependency-free PHP library for building OpenAPI specs with immutable, strongly-typed objects. Compose info, paths, operations, schemas, responses, and tags in code, then export the finished specification to JSON (YAML via another package).
Pros:
Schema::properties() method accepting SchemaContract instances improves type safety and reusability for complex nested schemas, aligning better with Laravel’s Eloquent relationships (e.g., hasMany, belongsTo).property() calls with SchemaContract instances for consistency).Cons:
Schema::properties() may require updates to existing custom schema definitions if they relied on the old method signature.SchemaContract support simplifies mapping Eloquent models to OpenAPI schemas, especially for polymorphic or deeply nested relationships (e.g., morphTo or hasManyThrough).@OA\Tag, @OA\Schema) can now leverage SchemaContract for cleaner property definitions, reducing redundancy.SchemaContract.SchemaContract can standardize token/claim definitions.toArray()/toResponseArray() can now directly map to SchemaContract instances, improving response schema accuracy.SchemaContract definitions are incomplete.openapi-linter) to compare specs against live API responses, with a focus on endpoints using SchemaContract.Schema::properties() with non-SchemaContract arguments may break.SchemaContract instances. Provide a migration script to automate this (e.g., regex search/replace in app/Models/).php artisan ooas:generate in build pipelines for static exports.SchemaContract adoption affect existing schemas?
Schema::properties() usage) be handled?SchemaContract-based specs?
SchemaContract instances?SchemaContract definitions and live API responses be resolved?SchemaContract?
SchemaContract standardize token payloads (e.g., Sanctum/Passport) or role-based access definitions?SchemaContract?SchemaContract simplify integration with packages like spatie/laravel-api or fruitcake/laravel-cors?Ooas\OoasServiceProvider as before, but update to leverage SchemaContract for global schema definitions (e.g., config/ooas.php)./api/docs) and exclude non-API routes.config/ooas.php to include default SchemaContract instances for common models (e.g., User, Token).SchemaContract with attributes (e.g., [#[Schema]] for models).doctrine/annotations for hybrid annotation styles.public folder or use darkaonline/l5-swagger for enhanced UI.stoplight/spectral in CI to validate SchemaContract-based specs.SchemaContract library (e.g., app/Contracts/OpenAPI/Schema) for reusable definitions.Schema::properties() usage and identify dependencies on non-SchemaContract arguments.SchemaContract instances (e.g., UserSchema::class)./api/v1/auth) to test SchemaContract adoption.SchemaContract for request/response models (e.g., CreateUserRequestSchema).Schema::properties() calls with SchemaContract instances for core models.SchemaContract-based annotations (e.g., @OA\RequestBody(ref="#/components/schemas/UserSchema")).SchemaContract and decorators.Schema::properties() usage in favor of SchemaContract.php artisan ooas:generate --strict to enforce SchemaContract compliance in CI.composer.json if using older Laravel/PHP stacks.[#[Schema]]) for cleaner syntax.zircote/swagger-php) to prevent duplicate specs.Ooas\Decorators\SpecDecorator to post-process specs (e.g., add missing security schemes).composer require goldspecdigital/oooas:^2.10.0.php artisan vendor:publish --provider="Ooas\OoasServiceProvider".config/ooas.php to include default SchemaContract instances.SchemaContract classes for critical models (e.g., app/Contracts/OpenAPI/UserSchema.php).namespace App\Contracts\OpenAPI;
use Ooas\Contracts\SchemaContract;
class UserSchema implements SchemaContract {
public function properties(): array {
return [
'id' => ['type' => 'integer'],
'name' => ['type' => 'string'],
'email' => ['type' => 'string', 'format' => 'email'],
];
}
}
Schema::properties() calls with SchemaContract references in annotations:
#[OA\RequestBody(ref="#/components/schemas/UserSchema")]
public function store(StoreUserRequest $request) { ... }
config/ooas.php.SchemaContract usage and spec accuracy:How can I help you explore Laravel packages today?