Skip to content

Conversation

@fernando-aviles
Copy link
Contributor

@fernando-aviles fernando-aviles commented Dec 29, 2025

Greptile Summary

This PR extends OpenAPI spec support from JSON-only to also include YAML (.yaml and .yml) formats, enabling Mintlify OpenAPI configuration to work with YAML spec files.

Key changes:

  • Added OPENAPI_SPEC_EXTENSIONS constant containing .json, .yaml, and .yml extensions
  • Updated buildSpecAnalyses() to parse YAML files using YAML.parse() alongside JSON parsing
  • Refactored spec path detection logic to use hasOpenApiSpecExtension() helper function
  • Added openapi preset to YamlSchema type definition and preset generation
  • Included comprehensive test coverage for YAML OpenAPI spec frontmatter rewrites

The implementation correctly handles YAML parsing, maintains backward compatibility with existing JSON specs, and includes proper error handling with updated warning messages.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, well-tested, and maintains backward compatibility. All changes are additive (extending JSON support to include YAML), with comprehensive test coverage including the new YAML path. The refactoring uses a helper function to centralize extension checking logic, error handling is appropriate, and the YAML parsing library is already imported and used elsewhere in the file.
  • No files require special attention

Important Files Changed

Filename Overview
packages/cli/src/utils/processOpenApi.ts Added YAML support for OpenAPI specs - robust implementation with proper parsing and extension checking
packages/cli/src/types/index.ts Extended YamlSchema type to support 'openapi' preset alongside existing 'mintlify' preset
packages/cli/src/config/optionPresets.ts Added 'openapi' case to YAML preset generation with appropriate JSONPath includes
packages/cli/src/utils/tests/processOpenApi.test.ts Added comprehensive test coverage for YAML OpenAPI spec support

Sequence Diagram

sequenceDiagram
    participant User
    participant processOpenApi
    participant buildSpecAnalyses
    participant fs
    participant YAML
    participant rewriteFrontmatter
    
    User->>processOpenApi: Process OpenAPI files
    processOpenApi->>buildSpecAnalyses: Build spec analyses from config files
    
    loop For each OpenAPI file
        buildSpecAnalyses->>fs: Check if file exists
        fs-->>buildSpecAnalyses: File exists
        buildSpecAnalyses->>buildSpecAnalyses: Extract extension (.json/.yaml/.yml)
        
        alt Extension not in OPENAPI_SPEC_EXTENSIONS
            buildSpecAnalyses->>buildSpecAnalyses: Warn and skip file
        else Valid extension
            buildSpecAnalyses->>fs: Read file content
            fs-->>buildSpecAnalyses: Raw file content
            
            alt Extension is .json
                buildSpecAnalyses->>buildSpecAnalyses: JSON.parse(raw)
            else Extension is .yaml or .yml
                buildSpecAnalyses->>YAML: YAML.parse(raw)
                YAML-->>buildSpecAnalyses: Parsed spec object
            end
            
            buildSpecAnalyses->>buildSpecAnalyses: Extract operations/schemas/webhooks
        end
    end
    
    buildSpecAnalyses-->>processOpenApi: Array of SpecAnalysis
    
    loop For each MDX/MD file
        processOpenApi->>rewriteFrontmatter: Rewrite frontmatter with localized spec paths
        rewriteFrontmatter->>rewriteFrontmatter: Parse openapi/openapi-schema values
        rewriteFrontmatter->>rewriteFrontmatter: hasOpenApiSpecExtension() checks for .json/.yaml/.yml
        rewriteFrontmatter->>rewriteFrontmatter: Resolve spec and generate localized path
        rewriteFrontmatter-->>processOpenApi: Updated content
        processOpenApi->>fs: Write updated file
    end
    
    processOpenApi-->>User: Processing complete
Loading

@fernando-aviles fernando-aviles requested a review from a team as a code owner December 29, 2025 18:37
@fernando-aviles fernando-aviles merged commit f0f86f3 into main Dec 29, 2025
19 checks passed
@fernando-aviles fernando-aviles deleted the f/openapi-yaml-support branch December 29, 2025 18:46
@github-actions github-actions bot mentioned this pull request Dec 29, 2025
ErnestM1234 pushed a commit that referenced this pull request Dec 29, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Patch Changes

- [#927](#927)
[`f0f86f3`](f0f86f3)
Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Adding
YAML support for Mintlify OpenAPI configurations

## [email protected]

### Patch Changes

- Updated dependencies
\[[`f0f86f3`](f0f86f3)]:
    -   [email protected]

<!-- greptile_comment -->

<h3>Greptile Summary</h3>


This is an automated release PR that publishes version updates for two
packages in response to the YAML support feature added in PR #927. The
PR correctly bumps `gtx-cli` from 2.5.39 to 2.5.40 (patch version),
updates `locadex` from 1.0.67 to 1.0.68 to reflect the dependency
update, and updates the corresponding CHANGELOG files with proper links
and attribution. The changeset file is automatically removed as part of
the release process. All changes follow standard semantic versioning
conventions and are consistent with the project's release workflow.

**Key changes:**
- Updated `gtx-cli` version to 2.5.40 with changelog entry documenting
YAML support for Mintlify OpenAPI configurations
- Updated `locadex` version to 1.0.68 with changelog entry reflecting
dependency update
- Removed temporary changeset file after release publication

<details open><summary><h3>Confidence Score: 5/5</h3></summary>


- This PR is safe to merge with minimal risk - it is a standard
automated release with correct version bumps and changelog updates
- Score of 5 reflects that this is an automated release PR with
straightforward changes: correct semver bumps, proper changelog
documentation, and expected removal of the changeset file. All version
numbers are consistent across package.json files and their corresponding
CHANGELOGs. The feature being released (YAML support) was already
thoroughly tested in PR #927, and this PR only handles the release
mechanics.
- No files require special attention
</details>


<details><summary><h3>Important Files Changed</h3></summary>




| Filename | Overview |
|----------|----------|
| packages/cli/package.json | Version bump from 2.5.39 to 2.5.40 for
gtx-cli release - correctly formatted semver patch version |
| packages/cli/CHANGELOG.md | CHANGELOG updated with new 2.5.40 entry
documenting YAML support for Mintlify OpenAPI configurations from PR
#927 |
| packages/locadex/package.json | Version bump from 1.0.67 to 1.0.68 for
locadex release due to updated gtx-cli dependency |
| packages/locadex/CHANGELOG.md | CHANGELOG updated with new 1.0.68
entry documenting updated dependencies ([email protected]) |

</details>


</details>


<details><summary><h3>Sequence Diagram</h3></summary>

```mermaid
sequenceDiagram
    participant Developer
    participant Changesets
    participant GitHub
    participant CI/CD
    participant npm
    
    Developer->>Changesets: Add changeset file to main branch
    Changesets-->>GitHub: Trigger release automation
    GitHub->>GitHub: Changesets action runs on merge
    GitHub->>GitHub: Update version in package.json (2.5.39 → 2.5.40)
    GitHub->>GitHub: Update version in package.json (1.0.67 → 1.0.68)
    GitHub->>GitHub: Update CHANGELOG.md with release notes
    GitHub->>GitHub: Remove changeset file
    GitHub->>CI/CD: Create release PR with changes
    Developer->>Developer: Review and merge release PR
    GitHub->>CI/CD: Trigger publish workflow
    CI/CD->>npm: Publish [email protected]
    CI/CD->>npm: Publish [email protected]
    npm-->>Developer: Packages available on npm registry
```
</details>


<!-- greptile_other_comments_section -->

<!-- /greptile_comment -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants