From 70bff49f715331039ba0d9ca0c7591b2bb3f58c4 Mon Sep 17 00:00:00 2001 From: David Biesack Date: Fri, 19 Jan 2024 09:08:31 -0500 Subject: [PATCH] Address PR comments --- README.md | 10 ++++++---- src/converter.ts | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fc16a6d..f384c94 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,11 @@ Options: --tokenUrl The tokenUrl for openIdConnect -> oauth2 transformation -d, --delete-examples-with-id If set, delete any JSON Schema examples that have an `id` property --oidc-to-oath2 Convert openIdConnect security to oath2. - --convertJsonComments if used, convert `$comment` in JSON schemas - to `x-comment`. I omitted, simply delete + --convertJsonComments If used, convert `$comment` in JSON schemas + to `x-comment`. If omitted, delete all `$comment` in JSON schemas. + (Use `--verbose` to log deletion + to stdout) -s, --scopes If set, this JSON/YAML file describes the OpenID scopes. This is an alias for --oidc-to-oath2 -v, --verbose Verbose output @@ -413,7 +415,7 @@ format: binary ## Unsupported down conversions -The tool does not support the following situations. +Curretnly, the tool does not support the following situations. Contributions welcome! * `openapi-down-convert` does not convert `exclusiveMinimum` and `exclusiveMaximum` @@ -423,7 +425,7 @@ Contributions welcome! * The tool only supports self-contained documents. It does not follow or resolve external `$ref` documents embedded in the source document. * Request body and response body `content` object transformations, such as - reversing `content: { 'application/octet-stream': {} }` + reversing `content: { 'application/octet-stream': {} }` as described in [Migrating from OpenAPI 3.0 to 3.1.0](https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0) * Converting other `contentEncoding` values (`7bit`, `8bit`, `binary`, `quoted-printable`, `base16`, `base32`) (Note: `contentEncoding: base64` is supported by diff --git a/src/converter.ts b/src/converter.ts index 07b9bbe..8a65904 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -113,9 +113,10 @@ export class Converter { } /** - * Log an rror message to console.error stream. Prefix the message string with `Error: ` - * if it does not already have that text. Increments the `returnCode`. - * @param message parameters for console.warn + * Log an error message to `console.error` stream. Prefix the message string with `Error: ` + * if it does not already start with `'Error'`. Increments the `returnCode`, causing + * the CLI to throw an Error when done. + * @param message parameters for `console.error` */ private error(...message) { if (!message[0].startsWith('Error')) { @@ -329,8 +330,8 @@ export class Converter { * ``` * format: byte * ``` - * in `type: string` schemas. Warn if schema has a `format` already. - * and it is not `byte` + * in `type: string` schemas. It is an error if the schema has a `format` already + * and it is not `byte`. */ convertJsonSchemaContentEncoding() { const schemaVisitor: SchemaVisitor = (schema: SchemaObject): SchemaObject => { @@ -348,7 +349,7 @@ export class Converter { } else { delete schema['contentEncoding']; schema['format'] = 'byte'; - this.log(` converted schema: contentEncoding: base64 to format: byte`); + this.log(`Converted schema: 'contentEncoding: base64' to 'format: byte'`); } } else { this.error(`Unable to down-convert contentEncoding: ${schema['contentEncoding']}`);