swagger-api / swagger-api/swagger-parser

Object schema property field data type validation of OpenAPIV3Parser

Open
#1,584 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Hi team
I'm using OpenAPIV3Parser for getting openapi specifications. This is the way I used to parse the openAPI yaml file

String openAPIFileContent = Files.readString(openapi.yaml);        
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true);
SwaggerParseResult parseResult = new OpenAPIV3Parser().readContents(openAPIFileContent, null, parseOptions);

Could you please let me know whether there is a way of getting datatype validation warnings or errors when I provide YAML with an invalid data type to the property data type?
sample of code: invalid field is id with datatype int.

...
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: int
        name:
          type: string

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

The payload names OpenAPIV3Parser, ParseOptions, and SwaggerParseResult; start by tracing how readContents reports parse problems when ParseOptions#setResolve(true) is used. Confirm whether the invalid type: int in the User schema is surfaced as a warning or error, and make that behavior explicit in coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.