Skip to content
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

fix: added missing response schemas + other improvements #3

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ info:
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: https://ossindex.sonatype.org/tos
title: Sonatype OSS Index
version: '2024.320'
version: '2024.323'
openapi: 3.0.1
paths:
/api/v3/authorized/component-report:
Expand All @@ -133,7 +134,13 @@ paths:
required: false
responses:
'200':
content: {}
content: &id001
application/json:
schema:
$ref: '#/components/schemas/ComponentReport'
application/vnd.ossindex.component-report-request.v1+json:
schema:
$ref: '#/components/schemas/ComponentReport'
description: Vulnerability report for components
'400':
content: {}
Expand Down Expand Up @@ -162,7 +169,7 @@ paths:
required: false
responses:
'200':
content: {}
content: *id001
description: Vulnerability report for components
'400':
content: {}
Expand Down Expand Up @@ -191,7 +198,7 @@ paths:
tags:
- Version
servers:
- url: /
- url: https://ossindex.sonatype.org
tags:
- name: Component vulnerability reports
- name: Version
Expand Down
24 changes: 24 additions & 0 deletions update-spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,33 @@
'name': 'Apache 2.0',
'url': 'http://www.apache.org/licenses/LICENSE-2.0.html'
},
'termsOfService': 'https://ossindex.sonatype.org/tos',
'version': OSS_INDEX_API_VERSION
}

print('Injecting correct `servers`')
json_spec['servers'] = [
{
'url': 'https://ossindex.sonatype.org'
}
]

# Fix Response Schemas
vuln_response = {
'application/json': {
'schema': {
'$ref': '#/components/schemas/ComponentReport'
}
},
'application/vnd.ossindex.component-report-request.v1+json': {
'schema': {
'$ref': '#/components/schemas/ComponentReport'
}
}
}
json_spec['paths']['/api/v3/component-report']['post']['responses']['200']['content'] = vuln_response
json_spec['paths']['/api/v3/authorized/component-report']['post']['responses']['200']['content'] = vuln_response

# Add `securitySchemes` under `components`
if 'components' in json_spec and 'securitySchemes' in json_spec['components'] and 'basicAuth' not in \
json_spec['components']['securitySchemes']:
Expand Down