Repository navigation
refactor: Separate pure OpenAPI helpers from documentation I/O - #37
sidneyswift wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
2 issues found across 13 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/docs/resolveReference.ts">
<violation number="1" location="lib/docs/resolveReference.ts:3">
P3: This new module has no direct unit test. Add `lib/docs/__tests__/resolveReference.test.ts` covering `~1`/`~0` pointer escapes, sibling keys overriding the target, external `$ref` passthrough, and a missing target. Per AGENTS.md, tests belong in `__tests__/` next to the code.</violation>
</file>
<file name="lib/docs/schemaExample.ts">
<violation number="1" location="lib/docs/schemaExample.ts:4">
P3: This new module has no unit test in `lib/docs/__tests__/`, which AGENTS.md expects for `lib/` functions. Add `lib/docs/__tests__/schemaExample.test.ts` covering nullable types, `oneOf`/`anyOf`, `allOf`, `$ref` resolution, and the depth cap.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| @@ -0,0 +1,10 @@ | |||
| import type { ApiObject } from "./apiObject.ts"; | |||
There was a problem hiding this comment.
P3: This new module has no direct unit test. Add lib/docs/__tests__/resolveReference.test.ts covering ~1/~0 pointer escapes, sibling keys overriding the target, external $ref passthrough, and a missing target. Per AGENTS.md, tests belong in __tests__/ next to the code.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/docs/resolveReference.ts, line 3:
<comment>This new module has no direct unit test. Add `lib/docs/__tests__/resolveReference.test.ts` covering `~1`/`~0` pointer escapes, sibling keys overriding the target, external `$ref` passthrough, and a missing target. Per AGENTS.md, tests belong in `__tests__/` next to the code.</comment>
<file context>
@@ -0,0 +1,10 @@
+import type { ApiObject } from "./apiObject.ts";
+
+export function resolveReference(value:ApiObject|undefined,spec:ApiObject):ApiObject {
+ if(!value)return {};
+ if(!value.$ref)return value;
</file context>
| @@ -0,0 +1,18 @@ | |||
| import type { ApiObject } from "./apiObject.ts"; | |||
There was a problem hiding this comment.
P3: This new module has no unit test in lib/docs/__tests__/, which AGENTS.md expects for lib/ functions. Add lib/docs/__tests__/schemaExample.test.ts covering nullable types, oneOf/anyOf, allOf, $ref resolution, and the depth cap.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/docs/schemaExample.ts, line 4:
<comment>This new module has no unit test in `lib/docs/__tests__/`, which AGENTS.md expects for `lib/` functions. Add `lib/docs/__tests__/schemaExample.test.ts` covering nullable types, `oneOf`/`anyOf`, `allOf`, `$ref` resolution, and the depth cap.</comment>
<file context>
@@ -0,0 +1,18 @@
+import type { ApiObject } from "./apiObject.ts";
+import { resolveReference } from "./resolveReference.ts";
+
+export function schemaExample(schema:ApiObject,spec:ApiObject,depth=0):unknown {
+ if(depth>5)return undefined;
+ schema=resolveReference(schema,spec);
</file context>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/docs/buildCurl.ts">
<violation number="1" location="lib/docs/buildCurl.ts:22">
P3: Bearer detection is case-sensitive. A spec declaring `"scheme": "Bearer"` (valid per OpenAPI, which treats the value case-insensitively) falls through to the `x-api-key` header. Compare with `String(scheme.scheme).toLowerCase()`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| const authHeaders = new Map<string, string>(); | ||
| const cookies = new Map<string, string>(); | ||
| for (const scheme of schemes) { | ||
| if (scheme.scheme === 'bearer') { |
There was a problem hiding this comment.
P3: Bearer detection is case-sensitive. A spec declaring "scheme": "Bearer" (valid per OpenAPI, which treats the value case-insensitively) falls through to the x-api-key header. Compare with String(scheme.scheme).toLowerCase().
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/docs/buildCurl.ts, line 22:
<comment>Bearer detection is case-sensitive. A spec declaring `"scheme": "Bearer"` (valid per OpenAPI, which treats the value case-insensitively) falls through to the `x-api-key` header. Compare with `String(scheme.scheme).toLowerCase()`.</comment>
<file context>
@@ -12,11 +12,28 @@ export function buildCurl({method,endpoint,spec,operation,pathItem={}}:{method:s
+ const authHeaders = new Map<string, string>();
+ const cookies = new Map<string, string>();
+ for (const scheme of schemes) {
+ if (scheme.scheme === 'bearer') {
+ authHeaders.set('Authorization', 'Bearer YOUR_TOKEN');
+ } else if (scheme.type === 'apiKey' && scheme.in === 'query') {
</file context>
| if (scheme.scheme === 'bearer') { | |
| if (scheme.scheme?.toLowerCase() === 'bearer') { |
Summary
Move reference resolution, schema examples and curl generation into pure focused modules; leave filesystem access and caching in docs-server. API source/generated contracts unchanged.
Verification
168 tests in 49 files, typecheck, lint and production build pass (538 pages). Independent reviewer verified the original extraction and repeated 32 migration/playground tests. A subsequent auth-rendering correction is documented below.
Scope and review
Part of the user-requested Recoup monorepo untangle-codebase workflow. Audit and decision log preceded implementation. Changes stay in this owning repository; no production deployment or main-branch merge requested. No broad comment/test-pruning sweep. Existing local work and retired checkouts preserved.
Each repository PR is independently reviewable; the Mono report will collect the coordinated audit, retained cases and check limitations.
Review follow-up
The curl renderer now emits every scheme in the selected first OpenAPI security requirement (AND), preserving first-alternative selection (OR), and places API keys in their declared header/query/cookie location. The actual guest claim needs both GuestSession cookie and BearerAuth; guest read needs its cookie. Five focused regressions failed before fixing. Added reference/example behavior cases bring the suite to 168 tests in 49 files; typecheck, lint and build (538 pages) pass. No endpoint authentication or API schema source changed.