redocly-cli
redocly-cli copied to clipboard
Spec validation error: `Errors: -info.contact.kiryuxa.com`
Describe the bug
Hi! I have multiple OpenAPI specs with same info section. I want to bundle them in one file using redocly join. For it I am using script:
#!/bin/bash
set -e
currentDir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
rootDir="$currentDir/../../../"
(cd "$rootDir/openapi" && exec rm -rf ./openapi.yml)
(cd "$rootDir/openapi" && exec redocly join \
./specs/common/ClientError.yml \
./specs/common/ServerError.yml \
-o ./openapi.yml)
(cd "$rootDir/client" && rm -rf ./src/generated)
(cd "$rootDir/client" &&
mkdir -p ./src/generated &&
touch ./src/generated/index.ts &&
touch ./src/generated/base.ts &&
touch ./src/generated/common.ts &&
touch ./src/generated/api.ts &&
touch ./src/generated/configuration.ts &&
touch ./src/generated/git_push.sh &&
touch ./src/generated/.gitignore &&
touch ./src/generated/.npmignore &&
touch ./src/generated/.openapi-generator-ignore
)
(cd "$rootDir" && exec docker run \
--rm \
-v "${PWD}/openapi:/local/openapi" \
-v "${PWD}/client/src/generated:/local/client/src/generated" \
openapitools/openapi-generator-cli:v7.8.0 generate \
--input-spec /local/openapi/openapi.yml \
--output /local/client/src/generated \
--generator-name typescript-axios \
--additional-properties=apiPackage=api,modelPackage=model,supportsES6=true,withSeparateModelsAndApi=true
)
(cd "$rootDir/server" && ./gradlew clean)
(cd "$rootDir/server" && exec ./gradlew openApiGenerate)
Added to Screenshots folder structure.
openapi/specs/common/ServerError.yml:
openapi: "3.1.0"
info:
description: Server Error
version: 1.0.0
title: Server Error
contact:
name: Kirill B
url: kiryuxa.com
email: [email protected]
paths: {}
components:
schemas:
ServerError:
type: object
required: [message]
properties:
message:
type: string
description: A description of the error.
example:
message: "Internal Server Error. Please try again later."
openapi/specs/common/ClientError.yml:
openapi: "3.1.0"
info:
description: Client Error
version: 1.0.0
title: Client Error
contact:
name: Kirill B
url: kiryuxa.com
email: [email protected]
paths: {}
components:
schemas:
ClientError:
type: object
required: [message]
properties:
message:
type: string
description: Error description
example:
message: "Client Error"
As I mentioned I am using command to bundle OpenAPI files to one file:
(cd "$rootDir/openapi" && exec redocly join \
./specs/common/ClientError.yml \
./specs/common/ServerError.yml \
-o ./openapi.yml)
But after executing command I gets an error:
╔═══════════════════════════════════════════════════════╗
║ ║
║ A new version of Redocly CLI (1.20.1) is available. ║
║ Update now: `npm i -g @redocly/cli@latest`. ║
║ Changelog: https://redocly.com/docs/cli/changelog/ ║
║ ║
╚═══════════════════════════════════════════════════════╝
./openapi.yml: join processed in 11ms
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 1, Warning count: 2
Errors:
-info.contact.kiryuxa.com
Warnings:
-info.contact.kiryuxa.com
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:717)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:744)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Expected behavior Bundle file, that contains section:
info:
description: Client Error (or Server Error, doesn't matter)
version: 1.0.0
title: Client Error
contact:
name: Kirill B
url: kiryuxa.com
email: [email protected]
Minimal reproducible OpenAPI snippet(if possible)
- Create
openapi/specs/common/ClientError.yml - Create
openapi/specs/common/ServerError.yml - Run from
openapifolder:
redocly join \
./specs/common/ClientError.yml \
./specs/common/ServerError.yml \
-o ./openapi.ym
Screenshots
Folder structure:
Additional context Add any other context about the problem here.