-
Notifications
You must be signed in to change notification settings - Fork 0
Add cli command for canonicalize oas document #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
toothlessdev
merged 7 commits into
develop
from
6-add-cli-command-for-canonicalize-oas-document
Jan 13, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f140ba1
build: semver ^ λ‘ λ³κ²½ (minor, patch λ§ λ°μ)
toothlessdev cb66e1b
feature: canonicalize cli command μΆκ°
toothlessdev 91746c6
docs: μ€λ³΅λ scope μ κ±°
toothlessdev 6fb5955
docs: μ€λ³΅λ scope μ κ±°
toothlessdev 8de884c
refactor: λΆνμν νμ
λ¨μΈ μ κ±°
toothlessdev eedfcd5
refactor: λΆνμν νμ
λ¨μΈ μ κ±°
toothlessdev 2857a1d
refactor: writeFile μ€ν¨μ exit 1 λ‘ μ’
λ£νλλ‘ μμ
toothlessdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,29 @@ | ||
| import { preprocessOASDocument } from "@patchlogr/oas"; | ||
| import { type OASStageOptions } from "@patchlogr/oas"; | ||
| import type { OpenAPI } from "openapi-types"; | ||
| import fs from "fs/promises"; | ||
|
|
||
| export type RunCanonicalizeOptions = OASStageOptions; | ||
| export type RunCanonicalizeOptions = OASStageOptions & { | ||
| output?: "stdout" | string; | ||
| }; | ||
|
|
||
| export async function runCanonicalize( | ||
| apiDocs: any, | ||
| apiDocs: OpenAPI.Document, | ||
| options: RunCanonicalizeOptions, | ||
| ) { | ||
| preprocessOASDocument(apiDocs, { ...options }); | ||
| const output = await preprocessOASDocument(apiDocs, { | ||
| skipValidation: !!options.skipValidation, | ||
| }); | ||
|
|
||
| if (options.output === "stdout" || options.output === undefined) { | ||
| console.log(JSON.stringify(output, null, 2)); | ||
| } else { | ||
| try { | ||
| await fs.writeFile(options.output, JSON.stringify(output, null, 2)); | ||
| } catch (error) { | ||
| throw new Error(`Failed to write to file ${options.output}:`, { | ||
| cause: error, | ||
| }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.