swagger-api / swagger-api/swagger-parser

SwaggerParser didn't return a validator messages when specification has schema with `additionalProperties` type `object` with reference

Open
#1,856 0 comments 1 reaction 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
Currently, I'm using the swagger parser for getting parsing OpenAPI objects from my given specification.

SwaggerParseResult parseResult = new OpenAPIV3Parser().readContents(openAPIFileContent, null, parseOptions);
        if (!parseResult.getMessages().isEmpty()) {
...
}

The used parser didn't return the validator for the schema which has additionalProperties type object and has a reference. but when it
Coding via the IDE returns as invalid usage of additionaltProperties.

IDE error
Screenshot from 2022-11-22 09-42-20

example for

components:
  schemas:
    User:
      type: object
      properties:
        name:
          type: string
        id:
          type: integer
    User01:
      description: Additional properties with objects with reference fields
      type: object
      properties:
        name:
          type: string
        id:
          type: integer
      additionalProperties:
        type: object
        $ref: "#/components/schemas/User"
   

Could you please let me know if is this regarding the version issue? I'm using the latest version 2.1.9

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 OpenAPIV3Parser.readContents entry point and reproduce the supplied OpenAPI example containing additionalProperties with type object and a $ref. Inspect how parseResult.getMessages() is populated during validation. Done means the parser reports the invalid additionalProperties usage instead of returning no validator messages.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.