Repository navigation
feat(portal): show each merged API's own SDK sample when the platform files samples by spec - #448
saeedjamshaid wants to merge 5 commits into
Conversation
The samples file from /portal-artifacts gains `specs` when the operations come from two or more
spec files: each spec's samples, keyed by its main file relative to `src/spec/`. A spec filed so
now takes its samples from its own group alone, and one with no group takes none. A file without
`specs` is placed as after #2297.
code-samples.json becomes `{ paths, specs }`, with `specs` keyed by slug, and a test holds the
CLI's and the template's declarations of it to one shape.
Refs apimatic/apimatic-io#2298
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w the samples are filed Whether an operation two specs declare shows an SDK sample now depends on the samples file, so the warning about it moves from the source to the placed samples, and prints once the samples arrive. It names the operations only when the samples are not filed by spec. Samples that no operation takes are checked within each spec when the samples are filed by spec, and the warning names that spec's file. Without the filing, the check and its message are as before. Both warnings now live in src/prompts/portal/code-samples.ts. Refs apimatic/apimatic-io#2298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second end-to-end build of the merged fixture gives each spec its own samples, as the platform files them, with `paths` holding the orders call for the operation both specs declare. Each status page shows its own API's call and not the other's. The two merged blocks now share their page paths and sample helper. Refs apimatic/apimatic-io#2298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es file at the template's The CLI's `CodeSamplesFile` now points to the template's declaration instead of restating it, as `PortalBuildPaths` does, and the placed samples' doc names the shared endpoints rather than repeating why they get no sample. Refs apimatic/apimatic-io#2298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re unplaced samples sit by path `UnplacedSamples.where` is the spec file, or `spec/` for the samples not filed by spec, in place of a null that needed a comment; that warning now names './spec', as other warnings name a folder. A catalog filed by spec answers no unfiled samples itself, and `undeclared` de-duplicates by the key it compares with. Refs apimatic/apimatic-io#2298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
I checked this against apimatic/codegen-v2#718, which writes
One gap: a
This can already happen in the apimatic/apimatic-io#2307 case. When a merged folder holds a Postman collection beside the OpenAPI document, Commons builds the SDK from the Postman file. The key then names the Postman file while the portal reads the OpenAPI one, so that API's pages lose every sample silently. Suggestion: warn once for each |
|
Keeping this as is, on purpose. A key that matches no spec has one cause: a merged folder that the platform builds from another file than the OpenAPI document the portal reads (apimatic-io issue 2307). There the whole API's SDK comes from the wrong file, so a warning about samples would name a symptom rather than the cause or the fix. 2307 refuses such a folder before the build and names the file to move, which also makes this case impossible. |



The problem
When two merged specs declare the same method and path, such as
GET /statuson two services, the platform's code samples hold one sample for the pair, keyed by path and method. The portal cannot tell whose it is, so since #435 it leaves the SDK sample off such an operation and warns.The platform is adding a grouping to its samples file. When the operations come from two or more spec files,
code-samples/<language>.jsongainsspecs: each spec's samples, keyed by its main file relative tosrc/spec/.pathsstays as it is, so released CLIs are unaffected.Tracked in apimatic-io issue 2298.
What changes
specs, each spec takes the samples filed under its own file, and only those. The file is matched exactly:orders/openapi.yamlforsrc/spec/orders/openapi.yaml. An operation two specs declare then shows each spec's own call. A spec with nothing filed under it shows no SDK sample, rather than calls frompathsthat may be another API's.specsis read as before. Every spec takespaths, less the operations two specs declare. Every samples file the platform sends today is of this kind.specs.code-samples.jsonchanges shape. The CLI writes this file for the template, and it becomes{ paths, specs }, withspecskeyed by section slug. Each section reads its own entry, orpaths. A test holds the CLI's and the template's declarations of the file to one shape, as it does forportal.config.json.src/prompts/portal/code-samples.ts;PortalSource.sharedEndpointsgoes, since the placed samples work out the shared operations.What it prints
Without
specs, the warning reads as before but prints after the samples arrive:A sample filed under a spec that declares no such operation:
Testing
pnpm testwithAPIMATIC_E2E=1, as CI runs it: 2052 passing, ESLint clean.specs, and refusing a malformedspecs;./orders/openapi.yaml,orders\openapi.yaml,Orders/openapi.yamland the folderordersmatch nothing, and a spec in a nested folder matches;constructor.GET /statuspages.specs.specsstill shows no SDK sample on either/statuspage.portal generateof the two-spec fixture. Production files have nospecsyet, so the result matches feat(portal): build a portal from the spec folders APIMATIC-META.json merges #435's:GET /statuswith both specs;Not in this PR
specs. The backend change is tracked in apimatic-io issue 2298.🤖 Generated with Claude Code