New Feature: #[OpenApiSpec] Attribute によるスペック名の宣言的指定#31
Merged
Conversation
…lution Introduce a PHP Attribute that allows test classes and methods to declaratively specify which OpenAPI spec to validate against, instead of relying solely on openApiSpec() overrides or the config default. Resolution priority: method attribute > class attribute > openApiSpec() override > config default_spec.
…agnostic use Extract OpenApiSpec attribute from Laravel namespace to Studio\OpenApiContractTesting and introduce OpenApiSpecResolver trait with an openApiSpecFallback() hook. The Laravel trait now composes OpenApiSpecResolver and overrides the fallback for config-based defaults.
…mous classes Replace anonymous class stubs in CreatesTestResponse with Symfony\Component\HttpFoundation\Response, fixing 3 PHPStan errors (missing generics, type mismatch, iterable type) at the root cause rather than suppressing them via ignore rules.
Widen from ^8.0 (PHP 8.4+ only) to ^6.4 || ^7.0 || ^8.0 so the package can be installed on PHP 8.2 and 8.3 in the CI matrix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
PHP Attribute
#[OpenApiSpec]を使って、テストクラスやテストメソッドに対して宣言的に OpenAPI スペック名を指定できるようにしました。従来のopenApiSpec()メソッドオーバーライドも引き続き動作します。変更内容
#[OpenApiSpec('spec-name')]Attribute クラスを追加(クラス・メソッド両方に対応)ValidatesOpenApiSchematrait にresolveOpenApiSpec()メソッドを追加し、以下の優先順位でスペック名を解決:#[OpenApiSpec]Attribute#[OpenApiSpec]AttributeopenApiSpec()メソッドのオーバーライドconfig('openapi-contract-testing.default_spec')#[OpenApiSpec]の使用案内を追記関連情報
openApiSpec()オーバーライドは完全に後方互換