Skip to content

Commit 406f3c2

Browse files
authored
Merge pull request #144 from urugator/feat-yaml-options
feat: yaml options. Thaks @urugator & @RobinTail
2 parents 4d89651 + 4d584ac commit 406f3c2

File tree

3 files changed

+60
-53
lines changed

3 files changed

+60
-53
lines changed

Changelog.md

+49-48
Original file line numberDiff line numberDiff line change
@@ -4,180 +4,181 @@
44

55
yyyy.mm.dd
66

7-
- Added basic documentation. Fix [#75](https://github.com/metadevpro/openapi3-ts/pull/75). PR[#139](https://github.com/metadevpro/openapi3-ts/pull/139)
7+
- Added basic documentation. Fix [#75](https://github.com/metadevpro/openapi3-ts/pull/75). PR[#139](https://github.com/metadevpro/openapi3-ts/pull/139)
8+
- Feat: `getSpecAsYaml` accepts the same options as `yaml.stringify`. Fix [#143](https://github.com/metadevpro/openapi3-ts/issues/143). PR[#144](https://github.com/metadevpro/openapi3-ts/pull/144)
89

910
## Version 4.3.3
1011

1112
2024.06.10
1213

13-
- Add mising types definitions. PR [#138](https://github.com/metadevpro/openapi3-ts/pull/138) by @andreujuanc
14+
- Add mising types definitions. PR [#138](https://github.com/metadevpro/openapi3-ts/pull/138) by @andreujuanc
1415

1516
## Version 4.3.2
1617

1718
2024.05.23
1819

19-
- Fix [#134](https://github.com/metadevpro/openapi3-ts/pull/134) exceisve files in distributed package. PR [136](https://github.com/metadevpro/openapi3-ts/pull/136) by @RobinTail
20+
- Fix [#134](https://github.com/metadevpro/openapi3-ts/pull/134) exceisve files in distributed package. PR [136](https://github.com/metadevpro/openapi3-ts/pull/136) by @RobinTail
2021

2122
## Version 4.3.1
2223

2324
2024.04.01
2425

25-
- Bug fix. `const` must be of type any. [#133](https://github.com/metadevpro/openapi3-ts/pull/133) by @RobinTail
26+
- Bug fix. `const` must be of type any. [#133](https://github.com/metadevpro/openapi3-ts/pull/133) by @RobinTail
2627

2728
## Version 4.3.0
2829

2930
2024.04.01
3031

31-
- Added support for `const` keyword [#132](https://github.com/metadevpro/openapi3-ts/pull/132) by @remidewitte
32-
- Update dependences.
32+
- Added support for `const` keyword [#132](https://github.com/metadevpro/openapi3-ts/pull/132) by @remidewitte
33+
- Update dependences.
3334

3435
## Version 4.2.2
3536

3637
2024.02.22
3738

38-
- Fixed [131](https://github.com/metadevpro/openapi3-ts/pull/131) `responses` to be optional by @remidewitte
39+
- Fixed [131](https://github.com/metadevpro/openapi3-ts/pull/131) `responses` to be optional by @remidewitte
3940

4041
## Version 4.2.1
4142

4243
2023.12.21
4344

44-
- Merged [#128](https://github.com/metadevpro/openapi3-ts/pull/128) Revert [#126](https://github.com/metadevpro/openapi3-ts/pull/128) `examples` typings by @RobinTail
45+
- Merged [#128](https://github.com/metadevpro/openapi3-ts/pull/128) Revert [#126](https://github.com/metadevpro/openapi3-ts/pull/128) `examples` typings by @RobinTail
4546

4647
2023.12.20
4748

48-
- Added [#126](https://github.com/metadevpro/openapi3-ts/pull/126) Adding contentEncoding and contentMediaType to 3.1 by @RobinTail
49-
- Updated dependencies
49+
- Added [#126](https://github.com/metadevpro/openapi3-ts/pull/126) Adding contentEncoding and contentMediaType to 3.1 by @RobinTail
50+
- Updated dependencies
5051

5152
## Version 4.1.2
5253

5354
2023.04.25
5455

55-
- Fix [#113](https://github.com/metadevpro/openapi3-ts/pull/113) Fix nullable on 3.0 types by @samchungy
56-
- Fix [#116](https://github.com/metadevpro/openapi3-ts/pull/116) Export with .mjs extension by @koooge
57-
- Fix [#117](https://github.com/metadevpro/openapi3-ts/pull/117) Support subpath for tsc with moduleResolutin node by @koooge
58-
- Fix [#118](https://github.com/metadevpro/openapi3-ts/pull/118) Bump yaml from 2.2.1 to 2.2.2
59-
- Update dependencies to latest.
56+
- Fix [#113](https://github.com/metadevpro/openapi3-ts/pull/113) Fix nullable on 3.0 types by @samchungy
57+
- Fix [#116](https://github.com/metadevpro/openapi3-ts/pull/116) Export with .mjs extension by @koooge
58+
- Fix [#117](https://github.com/metadevpro/openapi3-ts/pull/117) Support subpath for tsc with moduleResolutin node by @koooge
59+
- Fix [#118](https://github.com/metadevpro/openapi3-ts/pull/118) Bump yaml from 2.2.1 to 2.2.2
60+
- Update dependencies to latest.
6061

6162
## Version 4.1.1
6263

6364
2023.04.15
6465

65-
- Fix [#112](https://github.com/metadevpro/openapi3-ts/pull/112) Remove `nullable` & deprecate `example` in OAS 3.1 by @samchungy.
66+
- Fix [#112](https://github.com/metadevpro/openapi3-ts/pull/112) Remove `nullable` & deprecate `example` in OAS 3.1 by @samchungy.
6667

6768
## Version 4.1.0
6869

6970
2023.04.14
7071

71-
- [#111](https://github.com/metadevpro/openapi3-ts/pull/111) Improved exports by @koooge
72+
- [#111](https://github.com/metadevpro/openapi3-ts/pull/111) Improved exports by @koooge
7273

7374
## Version 4.0.4
7475

7576
2023.04.10
7677

77-
- [#108](https://github.com/metadevpro/openapi3-ts/pull/108) Bug fix: Remove any type from `paths` by @samchungy.
78-
- [#109](https://github.com/metadevpro/openapi3-ts/pull/109) Bug fix: Fixup types `example` & `prefixItems` by @samchungy.
78+
- [#108](https://github.com/metadevpro/openapi3-ts/pull/108) Bug fix: Remove any type from `paths` by @samchungy.
79+
- [#109](https://github.com/metadevpro/openapi3-ts/pull/109) Bug fix: Fixup types `example` & `prefixItems` by @samchungy.
7980

8081
## Version 4.0.3
8182

8283
2023.03.30
8384

84-
- Bug fix. Stricter TS compilation. Fix issue [#105](https://github.com/metadevpro/openapi3-ts/issues/105)
85+
- Bug fix. Stricter TS compilation. Fix issue [#105](https://github.com/metadevpro/openapi3-ts/issues/105)
8586

8687
## Version 4.0.2
8788

8889
2023.03.30
8990

90-
- PR [#104](https://github.com/metadevpro/openapi3-ts/pull/104) Fix export for cjs by @RobinTail
91+
- PR [#104](https://github.com/metadevpro/openapi3-ts/pull/104) Fix export for cjs by @RobinTail
9192

9293
## Version 4.0.1
9394

9495
2023.03.29
9596

96-
- Added instructions to README for consuing the library for v. 3.1.0 vs 3.0.0
97-
- PR [#100](https://github.com/metadevpro/openapi3-ts/pull/99) Fix typo by @RobinTail
98-
- PR [#99](https://github.com/metadevpro/openapi3-ts/pull/99) Fix typo by @RobinTail
99-
- PR [#97](https://github.com/metadevpro/openapi3-ts/pull/97) Export type `SchemaObjectType` by @RobinTail
100-
- PR [#96](https://github.com/metadevpro/openapi3-ts/pull/96) Support prefixItems by @samchungy
97+
- Added instructions to README for consuing the library for v. 3.1.0 vs 3.0.0
98+
- PR [#100](https://github.com/metadevpro/openapi3-ts/pull/99) Fix typo by @RobinTail
99+
- PR [#99](https://github.com/metadevpro/openapi3-ts/pull/99) Fix typo by @RobinTail
100+
- PR [#97](https://github.com/metadevpro/openapi3-ts/pull/97) Export type `SchemaObjectType` by @RobinTail
101+
- PR [#96](https://github.com/metadevpro/openapi3-ts/pull/96) Support prefixItems by @samchungy
101102

102103
## Version 4.0.0
103104

104105
2023.03.27
105106

106-
- Breaking change. Adds explicit support for OAS 3.0 and OAS 3.1 as separate implementations.
107+
- Breaking change. Adds explicit support for OAS 3.0 and OAS 3.1 as separate implementations.
107108

108109
## Version 3.2.0
109110

110-
- PR [#94](https://github.com/metadevpro/openapi3-ts/pull/94) Export type `SchemaObjectType`.
111-
- PR [#95](https://github.com/metadevpro/openapi3-ts/pull/95) Export type `SchemaObjectFormat`. Both contributed by @beautyfree
111+
- PR [#94](https://github.com/metadevpro/openapi3-ts/pull/94) Export type `SchemaObjectType`.
112+
- PR [#95](https://github.com/metadevpro/openapi3-ts/pull/95) Export type `SchemaObjectFormat`. Both contributed by @beautyfree
112113

113114
## Version 3.1.2
114115

115116
2022.11.19
116117

117-
- PR [#91](https://github.com/metadevpro/openapi3-ts/pull/91) Fix `addPath` to include merge semantics. Contributed by @MaurerKrisztian
118+
- PR [#91](https://github.com/metadevpro/openapi3-ts/pull/91) Fix `addPath` to include merge semantics. Contributed by @MaurerKrisztian
118119

119120
## Version 3.1.1
120121

121122
2022.10.10
122123

123-
- PR [#89](https://github.com/metadevpro/openapi3-ts/pull/89) Make Webhooks optional (not supportet in OPenAPI 3.0). Contributed by @samchungy
124+
- PR [#89](https://github.com/metadevpro/openapi3-ts/pull/89) Make Webhooks optional (not supportet in OPenAPI 3.0). Contributed by @samchungy
124125

125126
## Version 3.1.0
126127

127128
2022.10.06
128129

129-
- PR [#88](https://github.com/metadevpro/openapi3-ts/pull/88) Added support to Webhooks. Contributed by @samchungy
130+
- PR [#88](https://github.com/metadevpro/openapi3-ts/pull/88) Added support to Webhooks. Contributed by @samchungy
130131

131132
## Version 3.0.3
132133

133134
2022.10.06
134135

135-
- PR [#87](https://github.com/metadevpro/openapi3-ts/pull/87) Enable type array for schema object on OpenAPI 3.1. contributed by @samchungy
136+
- PR [#87](https://github.com/metadevpro/openapi3-ts/pull/87) Enable type array for schema object on OpenAPI 3.1. contributed by @samchungy
136137

137138
## Version 3.0.2
138139

139140
2022.08.29
140141

141-
- PR [#85](https://github.com/metadevpro/openapi3-ts/pull/85) Enable support for version 3.0.1 and 3.1.0 (Lax typing for `exclusiveMinimum` and `exclusiveMaximum`). contributed by @RobinTail
142+
- PR [#85](https://github.com/metadevpro/openapi3-ts/pull/85) Enable support for version 3.0.1 and 3.1.0 (Lax typing for `exclusiveMinimum` and `exclusiveMaximum`). contributed by @RobinTail
142143

143144
## Version 3.0.1
144145

145146
2022.08.16
146147

147-
- PR [#82](https://github.com/metadevpro/openapi3-ts/pull/82) Emit helpers for the CJS build. contributed by @RobinTail
148+
- PR [#82](https://github.com/metadevpro/openapi3-ts/pull/82) Emit helpers for the CJS build. contributed by @RobinTail
148149

149150
## Version 3.0.0
150151

151152
2022.08.07
152153

153-
- PR [#80](https://github.com/metadevpro/openapi3-ts/pull/80) contributed by @jonluca
154-
- Updated libs
155-
- Breaking change: Changed build system to output esm as well as cjs (folders `dist/mjs` and `dist/cjs` now respectively, instead of `dist` for cjs previously).
156-
- Changed test system to use vite
157-
- Added stricter extension prefix typing
154+
- PR [#80](https://github.com/metadevpro/openapi3-ts/pull/80) contributed by @jonluca
155+
- Updated libs
156+
- Breaking change: Changed build system to output esm as well as cjs (folders `dist/mjs` and `dist/cjs` now respectively, instead of `dist` for cjs previously).
157+
- Changed test system to use vite
158+
- Added stricter extension prefix typing
158159

159160
## Version 2.0.2
160161

161162
2022.02.17
162163

163-
- Updated libs
164+
- Updated libs
164165

165166
## Version 2.0.1
166167

167168
2020.12.31
168169

169-
- Updated testing libs
170-
- Added ESList + Prettier, removed TSList support
171-
- Refactor to be consistent with ESLint + Prettier code-style rules
172-
- No functional changes in this version: just end of year house-keeping.
170+
- Updated testing libs
171+
- Added ESList + Prettier, removed TSList support
172+
- Refactor to be consistent with ESLint + Prettier code-style rules
173+
- No functional changes in this version: just end of year house-keeping.
173174

174175
## Version 2.0.0
175176

176177
2020.09.18
177178

178-
- Added Yaml Support and the first dependence to `yaml` library. Thanks to @DMavani
179-
- Better typing for `type` and `format` properties. Thanks to @xeptore
180-
- Keeping extensibility on `format`.
179+
- Added Yaml Support and the first dependence to `yaml` library. Thanks to @DMavani
180+
- Better typing for `type` and `format` properties. Thanks to @xeptore
181+
- Keeping extensibility on `format`.
181182

182183
## Version 1.4.0
183184

src/dsl/openapi-builder30.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ export class OpenApiBuilder {
4545
): string {
4646
return JSON.stringify(this.rootDoc, replacer, space);
4747
}
48-
getSpecAsYaml(): string {
49-
return yaml.stringify(this.rootDoc);
48+
getSpecAsYaml(
49+
replacer?: Parameters<typeof yaml.stringify>[1],
50+
options?: Parameters<typeof yaml.stringify>[2]
51+
): string {
52+
return yaml.stringify(this.rootDoc, replacer, options);
5053
}
5154

5255
private static isValidOpenApiVersion(v: string): boolean {

src/dsl/openapi-builder31.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ export class OpenApiBuilder {
4545
): string {
4646
return JSON.stringify(this.rootDoc, replacer, space);
4747
}
48-
getSpecAsYaml(): string {
49-
return yaml.stringify(this.rootDoc);
48+
getSpecAsYaml(
49+
replacer?: Parameters<typeof yaml.stringify>[1],
50+
options?: Parameters<typeof yaml.stringify>[2]
51+
): string {
52+
return yaml.stringify(this.rootDoc, replacer, options);
5053
}
5154

5255
private static isValidOpenApiVersion(v: string): boolean {
@@ -182,4 +185,4 @@ export class OpenApiBuilder {
182185
this.rootDoc.webhooks[webhook] = webhookItem;
183186
return this;
184187
}
185-
}
188+
}

0 commit comments

Comments
 (0)