Skip to content

Commit b83d219

Browse files
committed
expand the info field to fully contain all optional openAPI info
1 parent 337ff33 commit b83d219

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/definitionGenerator.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,37 @@ class DefinitionGenerator {
6868
description: documentation?.description || '',
6969
version: documentation?.version || uuid(),
7070
}
71+
72+
if (documentation.termsOfService)
73+
info.termsOfService = documentation.termsOfService
74+
75+
if (documentation.contact) {
76+
const contactObj = {}
77+
contactObj.name = documentation.contact.name || ''
78+
79+
if (documentation.contact.url)
80+
contactObj.url = documentation.contact.url
81+
82+
contactObj.email = documentation.contact.email || ''
83+
Object.assign(info, {contact: contactObj})
84+
}
85+
86+
if (documentation.license && documentation.license.name) {
87+
const licenseObj = {}
88+
licenseObj.name = documentation.license.name || ''
89+
90+
if (documentation.license.url)
91+
licenseObj.url = documentation.license.url || ''
92+
93+
Object.assign(info, {license: licenseObj})
94+
}
95+
96+
for (const key of Object.keys(documentation)) {
97+
if (/^[x\-]/i.test(key)) {
98+
Object.assign(info, {[key]: documentation[key]})
99+
}
100+
}
101+
71102
Object.assign(this.openAPI, {info})
72103
}
73104

0 commit comments

Comments
 (0)