OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA] Setting data type to an invalid value is not failing the validation of OAS 3 using openapi-generator

Open
#16,726 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Setting the data type to an invalid value, e.g. type: uint32, is not being detected as an error when validating the OAS specification using openapi-generator-cli.
The command used to validate the spec is java -jar <path to openapi-generator-cli-7.0.1.jar> validate -i <path the to the minimal OAS example>.
The expected result is that validation should fail but it is not.

openapi-generator version

7.0.1. Not a regression, at least not since version 4.0.1.

OpenAPI declaration file content or url

This is the Pet Store example OAS with the error in it.

pet_store_openapi_with_error.txt This is a JSON file but I have renamed from .json to .txt to upload it. JSON type is not supported for upload.

Steps to reproduce

Importing the provided minimal OAS example will show an error in swagger online editor https://editor.swagger.io/
Structural error at components.schemas.ApiResponse.properties.code.type should be equal to one of the allowed values allowedValues: array, boolean, integer, number, object, string Jump to line 787
similar error shown by using using https://apidevtools.org/swagger-parser/online/.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the openapi-generator-cli validate command and the provided pet_store_openapi_with_error.txt example, then trace the validation path used for OAS 3 schemas. Confirm the invalid components.schemas.ApiResponse.properties.code.type value is rejected, matching the errors reported by Swagger Editor and Swagger Parser.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.