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

Spec validation error: Errors: -info.contact.kiryuxa.com #2572

Open
bas-kirill opened this issue Aug 22, 2024 · 0 comments
Open

Spec validation error: Errors: -info.contact.kiryuxa.com #2572

bas-kirill opened this issue Aug 22, 2024 · 0 comments

Comments

@bas-kirill
Copy link

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: baskirill.an@gmail.com

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: baskirill.an@gmail.com

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: baskirill.an@gmail.com

Minimal reproducible OpenAPI snippet(if possible)

  1. Create openapi/specs/common/ClientError.yml
  2. Create openapi/specs/common/ServerError.yml
  3. Run from openapi folder:
redocly join \
  ./specs/common/ClientError.yml \
  ./specs/common/ServerError.yml \
  -o ./openapi.ym

Screenshots
Folder structure:
image

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant