Skip to content

Comments

New Feature: openApiSpec() を config-based デフォルトに変更#13

Merged
wadakatu merged 3 commits intomainfrom
feat/config-based-default-spec
Feb 20, 2026
Merged

New Feature: openApiSpec() を config-based デフォルトに変更#13
wadakatu merged 3 commits intomainfrom
feat/config-based-default-spec

Conversation

@wadakatu
Copy link
Collaborator

概要

ValidatesOpenApiSchema trait の openApiSpec() を abstract メソッドから Laravel config ベースの具象メソッドに変更。openapi-contract-testing.default_spec config キーでプロジェクト全体のデフォルト spec を設定可能にし、必要な場合のみオーバーライドする形にする。

変更内容

  • openApiSpec() を abstract メソッドから config('openapi-contract-testing.default_spec', '') を返す具象メソッドに変更
  • OpenApiContractTestingServiceProvider を新規追加(mergeConfigFrom / publishes による config 管理)
  • config.php を新規追加(default_spec キー、デフォルト値は空文字)
  • composer.jsonextra.laravel.providers を追加し、Laravel Package Auto-Discovery を有効化
  • config 未設定時は空文字ガード(既存の L22-24)で明確なエラーメッセージを出力
  • namespace レベルの config() モックを用いた新規テスト 4 件を追加

関連情報

  • 前回の変更: commit b505a91 (feat!: replace openApiSpec property with abstract method)

Replace the abstract openApiSpec() method with a concrete method that
reads from Laravel config, allowing users to set a project-wide default
spec via the openapi-contract-testing.default_spec config key. Add a
service provider with publishable config for Laravel auto-discovery.
Add namespace-level config() mock helper and unit tests verifying that
the default openApiSpec() method reads from Laravel config, returns an
empty string when unconfigured, and fails with a clear message when
the spec name is empty.
- Validate config() return type with is_string guard for type safety
- Improve error message to mention config key and override option
- Update CLAUDE.md Laravel Integration section for new architecture
- Improve LaravelConfigMock docblock (correct package attribution,
  explain namespace mocking rationale, warn about use function imports)
- Extract shared CreatesTestResponse trait from duplicated helpers
- Add null config value test and update error message assertions
- Add explicit config() ignore in phpstan.neon.dist for trait file
@wadakatu wadakatu merged commit 5face67 into main Feb 20, 2026
8 checks passed
@wadakatu wadakatu deleted the feat/config-based-default-spec branch February 20, 2026 04:21
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