swagger-api / swagger-api/swagger-parser

Schema type incorrectly set when omitted and items given

Open
#1,763 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

Schema type incorrectly set when omitted and enums given

Swagger-parser version: 2.0.31

Sample spec:

openapi: 3.0.3
info:
  title: openapi 3.0.3 sample spec
  description: sample spec for testing openapi functionality, built from json schema
    tests for draft6
  version: 0.0.1
paths: {}
components:
  schemas:
    ASchemaGivenForItems:
      items:
        type: integer

When parsing the above schema, type should be unset on ASchemaGivenForItems
When one checks

  • ASchemaGivenForItems, the parser incorrectly set type to array when it should remain unset.

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 by reproducing the issue with the OpenAPI sample in the report and inspect how swagger-parser handles a schema with items but no type. Add a regression check showing that ASchemaGivenForItems keeps type unset, then run the relevant parser tests to confirm the correction.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.