Skip to content

Fix: Remove fabricated server URL and address cleanup issues#70

Merged
nrynss merged 2 commits into
mainfrom
vibe/fix-server-url-and-cleanup-3782d2
Jun 27, 2026
Merged

Fix: Remove fabricated server URL and address cleanup issues#70
nrynss merged 2 commits into
mainfrom
vibe/fix-server-url-and-cleanup-3782d2

Conversation

@nrynss

@nrynss nrynss commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Changes

1. Fabricated Server URL (#52)

  • File: src/utils.rs
  • Change: Removed the fallback that pushed "https://api.example.com" when no servers were declared in the spec.
  • Impact: The renderer already skips the "Server URLs" section when the list is empty, so no output change for specs with servers. For specs without servers, no fabricated URL is shown.

2. Request Body Media Types (#56)

  • File: src/parser.rs
  • Change: Iterate over all media types in req_body.content instead of just the first.
  • Impact: When a request body offers multiple media types (e.g., JSON + XML), each is now documented as a separate parameter with the content type in parentheses (e.g., requestBody (application/json)).

3. Anchor Collisions (#56)

  • Files: src/markdown/endpoint.rs, src/markdown/views.rs
  • Change: Include HTTP method and path in endpoint anchors (e.g., #get-pets instead of #listpets).
  • Impact: Ensures unique anchors even when multiple endpoints share the same title/summary.

Testing

  • All existing tests pass (36 passed)
  • Manually verified:
    • No fabricated server URL for specs without servers
    • Multiple media types are documented for request bodies
    • Anchors are unique even for endpoints with identical titles

Fixes #52 and #56.

mistral-vibe and others added 2 commits June 27, 2026 13:38
- Fix #52: Remove fallback that fabricates 'https://api.example.com' when spec
  declares no servers. The renderer already skips the Server URLs section when
  the list is empty.
- Fix #56: Request body now documents all media types instead of just the first.
  When multiple media types are present, each gets its own parameter with the
  content type in parentheses (e.g., 'requestBody (application/json)').
- Fix #56: Anchor collisions are resolved by including the HTTP method and path
  in endpoint anchors, ensuring uniqueness even when endpoints share the same
  title.

Fixes #52 and #56.

Co-authored-by: nrynss <[email protected]>
@nrynss nrynss marked this pull request as ready for review June 27, 2026 14:16
@nrynss nrynss merged commit 9cbfa12 into main Jun 27, 2026
9 checks passed
@nrynss nrynss deleted the vibe/fix-server-url-and-cleanup-3782d2 branch June 27, 2026 14:17
nrynss added a commit that referenced this pull request Jun 27, 2026
Issue #58: schema rendering is now memoized per document. Component
schemas reached through a `$ref` are expanded once into a trailing
"Schema Definitions" section and linked from every use site instead of
being re-inlined at each occurrence, cutting output and token cost for
specs with shared schemas. `--inline-schemas` restores the fully
self-contained expansion (with cycle detection) for callers that want it.

The previous commit only added unused, unformatted infrastructure to
schema.rs (CI red on `cargo fmt --check`, nothing wired in). That is
replaced with a clean, fully integrated implementation:

- `SchemaContext` threads through each body view → `write_endpoint` →
  `write_schema_table`; `render_schema_definitions` emits the shared
  section once per document. Self/mutual references resolve to links, so
  cycles need no special-casing in linked mode. Anchors are allocated
  collision-free and the section is rendered in deterministic
  first-encounter order.

Follow-ups to the previously merged PRs:

- #69: the "no effect" warning now reports the detail level in the
  lowercase spelling the user types (`--detail standard`), not the
  Debug-derived `Standard`. `--inline-schemas` without `--include-schemas`
  warns too.
- #70: endpoint heading anchors are scoped by service in the service
  view, so a multi-tag operation rendered under several sections gets a
  unique anchor each time and its TOC links stay unambiguous.

Tests: linked-default expansion + dedup, self-reference-as-link, inline
mode, inline-mode cycle detection, warning casing, and multi-tag anchor
uniqueness (new `multi_tag_oas3.json` fixture). 43 pass; fmt and clippy
clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
nrynss added a commit that referenced this pull request Jun 27, 2026
* Add schema memoization infrastructure for issue #58

Implements SchemaContext with document-level memoization to avoid
re-expanding shared sub-schemas at every use site.

Key changes:
- Add SchemaContext struct for tracking expanded schema references
- Add write_schema_table_with_context for memoized schema rendering
- Add collect_schema_rows_with_memo that avoids duplicate expansion
- Add render_deferred_schemas for rendering schema definitions at end
- Preserve original functions for backward compatibility

This addresses the output/token bloat issue where shared schemas
(like Error models) were being fully re-expanded at every reference.

The implementation uses:
- HashSet for tracking expanded references
- Markdown links for cross-references to already-expanded schemas
- Deferred rendering of schema definitions in a dedicated section
- Proper cycle detection with links to existing schemas

Note: The new functions are implemented but not yet integrated
into the main rendering pipeline. The original functions remain
functional and all existing tests pass.

Co-authored-by: nrynss <[email protected]>

* Integrate schema memoization and fix follow-ups from #69/#70

Issue #58: schema rendering is now memoized per document. Component
schemas reached through a `$ref` are expanded once into a trailing
"Schema Definitions" section and linked from every use site instead of
being re-inlined at each occurrence, cutting output and token cost for
specs with shared schemas. `--inline-schemas` restores the fully
self-contained expansion (with cycle detection) for callers that want it.

The previous commit only added unused, unformatted infrastructure to
schema.rs (CI red on `cargo fmt --check`, nothing wired in). That is
replaced with a clean, fully integrated implementation:

- `SchemaContext` threads through each body view → `write_endpoint` →
  `write_schema_table`; `render_schema_definitions` emits the shared
  section once per document. Self/mutual references resolve to links, so
  cycles need no special-casing in linked mode. Anchors are allocated
  collision-free and the section is rendered in deterministic
  first-encounter order.

Follow-ups to the previously merged PRs:

- #69: the "no effect" warning now reports the detail level in the
  lowercase spelling the user types (`--detail standard`), not the
  Debug-derived `Standard`. `--inline-schemas` without `--include-schemas`
  warns too.
- #70: endpoint heading anchors are scoped by service in the service
  view, so a multi-tag operation rendered under several sections gets a
  unique anchor each time and its TOC links stay unambiguous.

Tests: linked-default expansion + dedup, self-reference-as-link, inline
mode, inline-mode cycle detection, warning casing, and multi-tag anchor
uniqueness (new `multi_tag_oas3.json` fixture). 43 pass; fmt and clippy
clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Vibe Nuage Agent <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

Cleanup: minor correctness issues found during source audit Bug: fabricated default server URL when spec declares none

2 participants