코드에만 존재하던 REST API 계약(약 663 엔드포인트)을 코어/확장 책임별로
분리된 마크다운 레퍼런스로 전면 문서화한다. 674개 규모에서 수기 문서는
반드시 drift 하므로 "코드 추출 → 스캐폴딩 → 사람이 서술 채움 → 하네스가
커버리지 강제" 하이브리드로 구성했다.
추출 파이프라인 (app/Support/ApiDoc):
- ApiRouteInventory / FormRequestIntrospector / ApiEndpointProbe(실측 HTTP) /
ResponseSchemaInferrer / ApiDocScaffolder / ColumnCommentResolver /
ResourceFieldDescriber / ParameterDescriber
- api:docgen 커맨드(--scope/--seed/--check/--dry-run/--base-url/--user) +
응답/파라미터 in-place 백필 커맨드 2종(재생성 없이 TODO 셀만 치환, 멱등)
- ApiDocSampleSeeder 계약 + 코어/확장 시더로 실측용 완전 샘플 멱등 생성
문서화 (실측 기반, GET read-only 실호출):
- 코어 291엔드포인트 35파일(docs/backend/api) + 규정 docs/backend/api-documentation.md
- 확장: ecommerce(231)·board(80)·page(17)·hello_module(2)·pay_kginicis(22)·
gdpr(15)·ckeditor5(2)·marketing(2)·verification_kginicis(1)
- 표준 4구성(헤더·요청 파라미터·응답 필드·에러 표) + 엔드포인트 용도 서술
- 파라미터 용도·응답 필드 설명 셀 전수 채움(도메인 지식 수기)
하네스:
- audit 룰 api-doc-coverage — API 표면(라우트/컨트롤러/FormRequest/Resource)
변경 시 대응 문서 미동반이면 차단. 전 대상 문서 완비로 error 승격
- file-rules 리마인더(컨트롤러/라우트 편집 시), coverage.json, dev-dashboard 카드
- docs/backend/routing.md 확장 공개 API URL 스킴 정정(/api/modules|plugins/{id})
- /AGENTS.md/docs-index 동기
66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Sirsoft\Page\Tests\Unit\Support;
|
|
|
|
use App\Contracts\ApiDoc\ApiDocSampleSeeder;
|
|
use Modules\Sirsoft\Page\Models\Page;
|
|
use Modules\Sirsoft\Page\Support\ApiDoc\ApiDocSampleService;
|
|
use Modules\Sirsoft\Page\Tests\ModuleTestCase;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
|
|
/**
|
|
* sirsoft-page API 문서 실측용 완전 샘플 시더 테스트.
|
|
*
|
|
* 페이지 도메인 대표 샘플이 발행 상태로 생성되고(상세 GET 실측 가능),
|
|
* 버전 이력·첨부가 조립되며, 재실행 시 멱등한지 검증한다.
|
|
*/
|
|
class ApiDocSampleServiceTest extends ModuleTestCase
|
|
{
|
|
#[Test]
|
|
public function 시더는_계약을_구현한다(): void
|
|
{
|
|
$this->assertInstanceOf(ApiDocSampleSeeder::class, new ApiDocSampleService);
|
|
}
|
|
|
|
#[Test]
|
|
public function 페이지_도메인_대표_샘플_맵을_반환한다(): void
|
|
{
|
|
$map = (new ApiDocSampleService)->seed();
|
|
|
|
$this->assertArrayHasKey('pages', $map);
|
|
$this->assertSame(Page::class, $map['pages']['model']);
|
|
$this->assertArrayHasKey('key', $map['pages']);
|
|
$this->assertNotEmpty($map['pages']['value']);
|
|
}
|
|
|
|
#[Test]
|
|
public function 대표_샘플_페이지는_발행_상태로_버전_이력과_첨부를_갖는다(): void
|
|
{
|
|
(new ApiDocSampleService)->seed();
|
|
|
|
$page = Page::query()->where('slug', 'apidoc-sample-page')->first();
|
|
|
|
$this->assertNotNull($page);
|
|
$this->assertTrue($page->published);
|
|
$this->assertNotNull($page->published_at);
|
|
$this->assertNotNull($page->seo_meta);
|
|
$this->assertSame(2, $page->versions()->count());
|
|
$this->assertSame(1, $page->attachments()->count());
|
|
}
|
|
|
|
#[Test]
|
|
public function 재실행_시_샘플이_중복_생성되지_않는다(): void
|
|
{
|
|
$service = new ApiDocSampleService;
|
|
|
|
$service->seed();
|
|
$countAfterFirst = Page::query()->where('slug', 'apidoc-sample-page')->count();
|
|
|
|
$service->seed();
|
|
$countAfterSecond = Page::query()->where('slug', 'apidoc-sample-page')->count();
|
|
|
|
$this->assertSame(1, $countAfterFirst);
|
|
$this->assertSame(1, $countAfterSecond);
|
|
}
|
|
}
|