Skip to content

Commit dd1be0e

Browse files
authored
Merge pull request #3 from sonatype-nexus-community/fix/response-schemas
fix: added missing response schemas + other improvements
2 parents 5af8eac + 518dc90 commit dd1be0e

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

spec/openapi.yaml

+11-4
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ info:
115115
license:
116116
name: Apache 2.0
117117
url: http://www.apache.org/licenses/LICENSE-2.0.html
118+
termsOfService: https://ossindex.sonatype.org/tos
118119
title: Sonatype OSS Index
119-
version: '2024.320'
120+
version: '2024.323'
120121
openapi: 3.0.1
121122
paths:
122123
/api/v3/authorized/component-report:
@@ -133,7 +134,13 @@ paths:
133134
required: false
134135
responses:
135136
'200':
136-
content: {}
137+
content: &id001
138+
application/json:
139+
schema:
140+
$ref: '#/components/schemas/ComponentReport'
141+
application/vnd.ossindex.component-report-request.v1+json:
142+
schema:
143+
$ref: '#/components/schemas/ComponentReport'
137144
description: Vulnerability report for components
138145
'400':
139146
content: {}
@@ -162,7 +169,7 @@ paths:
162169
required: false
163170
responses:
164171
'200':
165-
content: {}
172+
content: *id001
166173
description: Vulnerability report for components
167174
'400':
168175
content: {}
@@ -191,7 +198,7 @@ paths:
191198
tags:
192199
- Version
193200
servers:
194-
- url: /
201+
- url: https://ossindex.sonatype.org
195202
tags:
196203
- name: Component vulnerability reports
197204
- name: Version

update-spec.py

+24
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,33 @@
5858
'name': 'Apache 2.0',
5959
'url': 'http://www.apache.org/licenses/LICENSE-2.0.html'
6060
},
61+
'termsOfService': 'https://ossindex.sonatype.org/tos',
6162
'version': OSS_INDEX_API_VERSION
6263
}
6364

65+
print('Injecting correct `servers`')
66+
json_spec['servers'] = [
67+
{
68+
'url': 'https://ossindex.sonatype.org'
69+
}
70+
]
71+
72+
# Fix Response Schemas
73+
vuln_response = {
74+
'application/json': {
75+
'schema': {
76+
'$ref': '#/components/schemas/ComponentReport'
77+
}
78+
},
79+
'application/vnd.ossindex.component-report-request.v1+json': {
80+
'schema': {
81+
'$ref': '#/components/schemas/ComponentReport'
82+
}
83+
}
84+
}
85+
json_spec['paths']['/api/v3/component-report']['post']['responses']['200']['content'] = vuln_response
86+
json_spec['paths']['/api/v3/authorized/component-report']['post']['responses']['200']['content'] = vuln_response
87+
6488
# Add `securitySchemes` under `components`
6589
if 'components' in json_spec and 'securitySchemes' in json_spec['components'] and 'basicAuth' not in \
6690
json_spec['components']['securitySchemes']:

0 commit comments

Comments
 (0)