feat: adding support for yaml in mintlify openapi config #927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Summary
This PR extends OpenAPI spec support from JSON-only to also include YAML (
.yamland.yml) formats, enabling Mintlify OpenAPI configuration to work with YAML spec files.Key changes:
OPENAPI_SPEC_EXTENSIONSconstant containing.json,.yaml, and.ymlextensionsbuildSpecAnalyses()to parse YAML files usingYAML.parse()alongside JSON parsinghasOpenApiSpecExtension()helper functionopenapipreset toYamlSchematype definition and preset generationThe 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
Important Files Changed
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