fix: ensure header keys are case-insensitive#251
Conversation
WalkthroughRequestBuilder.header now normalizes header names to lowercase before assignment (builds a normalizedHeaders map and assigns it to this.config.requestHeaders); method signature and return value unchanged. OpenAPIGenerator selection now checks for an Authorization header case-insensitively by testing for "authorization" in result.request.headers. SecurityBuilder.extractSecurityRequirements likewise uses the lowercase "authorization" key when extracting header values. examples/express/expected/oas.json renamed several header parameter names (e.g., X-Request-ID → x-request-id, Accept → accept, Accept-Language → accept-language). No exported/public signatures changed. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/dsl/test-builders/RequestBuilder.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/dsl/test-builders/RequestBuilder.ts (1)
lib/dsl/interface/field.ts (1)
DSLField(30-34)
🔇 Additional comments (1)
lib/dsl/test-builders/RequestBuilder.ts (1)
28-28: LGTM: Clear documentation of normalization behavior.The updated docstring accurately describes that header names are normalized to lowercase, which aligns with the HTTP specification's requirement for case-insensitive header handling.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
examples/express/expected/oas.json(5 hunks)
🔇 Additional comments (1)
examples/express/expected/oas.json (1)
645-645: Lowercasing header parameter names SGTMNormalizing header keys to lowercase keeps the OpenAPI document consistent with the new request builder behavior without affecting semantics.
Also applies to: 1183-1183, 1192-1192
* fix: apply header key normalized to lowercase * update expected oas.json
* fix: apply header key normalized to lowercase * update expected oas.json
* fix: apply header key normalized to lowercase * update expected oas.json
* create dsl req().file() for upload single file api * create fileField dsl sample. * create examples/express for testing file upload api * sample tests * add some validate fileField * update * write example itdoc for octstream api * revert package.json to original * refactor: fileField remove now, just direct pass args with `.req().file(...)` * test refactor * clean up * 기본적인 문서 작성 * review apply. thx rabbit~ * revert it * review apply. logic fix - thx rabbit~ * logic enhance * review apply * fix validate * apply review : type specific * fix: ensure header keys are case-insensitive (#251) * fix: apply header key normalized to lowercase * update expected oas.json * revert package.json * fix logic error
* create dsl req().file() for upload single file api * create fileField dsl sample. * create examples/express for testing file upload api * sample tests * add some validate fileField * update * write example itdoc for octstream api * revert package.json to original * refactor: fileField remove now, just direct pass args with `.req().file(...)` * test refactor * clean up * 기본적인 문서 작성 * review apply. thx rabbit~ * revert it * review apply. logic fix - thx rabbit~ * logic enhance * review apply * fix validate * apply review : type specific * fix: ensure header keys are case-insensitive (#251) * fix: apply header key normalized to lowercase * update expected oas.json * revert package.json * fix logic error
ko
표준에 따르면 header key는 대소문자 구분이 되면 안됩니다.
하지만 현재 itdoc에서는 아래와 같은 테스트가 작성되면 내부 동작이 달라질 수 있습니다.
대소문자 정규화가 되지 않기 때문에, 아래와 같은 코드들이 동작되지 않을 수 있습니다.
이런 버그를 수정했습니다.
en
According to the specification, header keys must not be case-sensitive.
However, in itdoc, if tests are written like the following, the internal behavior may differ:
Because header keys are not normalized, certain code paths may not work as expected:
closed #250
Summary by CodeRabbit