Skip to content

Commit

Permalink
Update src/third-version.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Maciej Urbańczyk <[email protected]>
  • Loading branch information
jonaslagoni and magicmatatjahu authored Jul 24, 2023
1 parent c6e164b commit da787bc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/third-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,25 @@ function convertParameters(parameters: Record<string, any>): Record<string, any>
* Does not include extensions from schema.
*/
function convertParameter(parameter: any): any {
const ref = parameter['$ref'] ?? null;
if(ref !== null) {
return {
$ref: ref
}
}

const enumValues = parameter.schema?.enum ?? null;
const defaultValues = parameter.schema?.default ?? null;
const description = parameter.description ?? parameter.schema?.description ?? null;
const examples = parameter.schema?.examples ?? null;
const location = parameter.location ?? null;
const ref = parameter['$ref'] ?? null;

//Make sure we keep parameter extensions
const v2ParameterObjectProperties = ["location", "schema", "description", "$ref"];
const v2ParameterObjectProperties = ["location", "schema", "description"];
const v2ParameterObjectExtensions = Object.entries(parameter).filter(([key,]) => {
return !v2ParameterObjectProperties.includes(key);
});

if(ref !== null) {
return {
$ref: ref
}
}

//Return the new v3 parameter object
return Object.assign({...v2ParameterObjectExtensions},
enumValues === null ? null : {enum: enumValues},
Expand Down

0 comments on commit da787bc

Please sign in to comment.