From 77a6f6625614ce791e51ab52b736b968075a92d2 Mon Sep 17 00:00:00 2001 From: Paul Horton Date: Wed, 20 Nov 2024 17:26:05 +0000 Subject: [PATCH] fix: response schema for `POST /api/v2/components/remediation/{ownerType}/{ownerId}` Signed-off-by: Paul Horton --- spec/openapi.yaml | 17 ++++------------- update-spec.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/spec/openapi.yaml b/spec/openapi.yaml index c1d33e5..bead281 100644 --- a/spec/openapi.yaml +++ b/spec/openapi.yaml @@ -4720,19 +4720,10 @@ paths: $ref: '#/components/schemas/ApiComponentDTOV2' responses: '200': - description: 'The response returns details for components that can be used - for remediation. Details for the recommended component are grouped under - type in the response.

Hash values returned here are truncated - and are not intended to be used as checksums. They can be used as identifiers - to pass to other REST API calls. ' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiComponentRemediationValueDTO' tags: - Components /api/v2/components/versions: diff --git a/update-spec.py b/update-spec.py index 48f9880..e93c291 100644 --- a/update-spec.py +++ b/update-spec.py @@ -296,13 +296,28 @@ for content_type in json_spec['paths'][path][method]['requestBody']['content']: if '$ref' in json_spec['paths'][path][method]['requestBody']['content'][content_type]['schema']: if json_spec['paths'][path][method]['requestBody']['content'][content_type]['schema'][ - '$ref'] == ref_to_find: + '$ref'] == ref_to_find: json_spec['paths'][path][method]['requestBody']['content'][content_type]['schema'][ '$ref'] = ref_to_replace_with # v184 Updates # ------------------------------------------------------------------------ +# Fix Response schema for POST /api/v2/components/remediation/{ownerType}/{ownerId} +if 'paths' in json_spec and '/api/v2/components/remediation/{ownerType}/{ownerId}' in json_spec['paths']: + if 'post' in json_spec['paths']['/api/v2/components/remediation/{ownerType}/{ownerId}']: + print('Fixing POST /api/v2/components/remediation/{ownerType}/{ownerId}...') + json_spec['paths']['/api/v2/components/remediation/{ownerType}/{ownerId}']['post']['responses'][ + '200'] = { + 'content': { + 'application/json': { + 'schema': { + '$ref': '#/components/schemas/ApiComponentRemediationValueDTO' + } + } + } + } + # Coerce `default` responses to be `200` for path in json_spec['paths']: for method in json_spec['paths'][path]: