Skip to content

Commit b9fa178

Browse files
committed
release 1.29.2
1 parent 080e344 commit b9fa178

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## unreleased
22

3+
## [1.29.2] - 2025-12-22
4+
35
- Doc: Added documentation for module usage
46
- Module: Handle default sort sets
57
- Removed commander dependency

readme.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,23 +1587,33 @@ Both `sortSet` and `sortComponentsSet` are optional when you call `openapiSort`.
15871587
### Sorting with minimal setup
15881588

15891589
```js
1590-
const {openapiSort} = require('openapi-format');
1591-
const fs = require('fs');
1590+
const {
1591+
parseFile,
1592+
stringify,
1593+
writeFile,
1594+
openapiSort
1595+
} = require('openapi-format');
15921596
1593-
const document = JSON.parse(fs.readFileSync('spec.json', 'utf8'));
1594-
const {data} = await openapiSort(document, {sort: true});
1597+
const input = await parseFile('spec.json'); // local path or remote URL
1598+
const {data} = await openapiSort(input, {sort: true});
15951599
1596-
fs.writeFileSync('spec.sorted.json', JSON.stringify(data, null, 2));
1600+
const output = await stringify(data, {format: 'json'});
1601+
await writeFile('spec.sorted.json', output, {format: 'json'});
15971602
```
15981603

15991604
### Sorting with custom tweaks
16001605

16011606
```js
16021607
const {
1608+
parseFile,
1609+
stringify,
1610+
writeFile,
16031611
openapiSort,
16041612
getDefaultSortSet
16051613
} = require('openapi-format');
16061614
1615+
const document = await parseFile('spec.json');
1616+
16071617
const sortSet = await getDefaultSortSet();
16081618
sortSet.get = ['summary', 'description', 'responses']; // override GET priority
16091619
@@ -1612,14 +1622,17 @@ const {data} = await openapiSort(document, {
16121622
sortSet,
16131623
sortComponentsSet: ['schemas', 'responses']
16141624
});
1625+
1626+
const output = await stringify(data, {format: 'json'});
1627+
await writeFile('spec.sorted.json', output, {format: 'json'});
16151628
```
16161629

16171630
### Mixing in other utilities
16181631

16191632
```js
16201633
const {openapiFilter, openapiGenerate} = require('openapi-format');
16211634
1622-
let draft = /* load OpenAPI */;
1635+
let draft = await parseFile('spec.json');
16231636
draft = (await openapiFilter(draft, {
16241637
filterSet: {tags: ['public']}
16251638
})).data;

0 commit comments

Comments
 (0)