swagger-api / swagger-api/swagger-parser

3.1.0 spec procesing, nonexistant types added

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

When parsing this spec:

# OAS document that uses 3.1 features:
# 'null' type
# type array
openapi: 3.1.0
info:
  version: 1.0.0
  title: Example
  license:
    name: MIT
    identifier: MIT
servers:
  - url: http://api.example.xyz/v1
paths:
  /somePath:
    get:
      operationId: getSomePath
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema: {}
components:
  schemas:
    ArrayContainsValue:
      type: array
      contains:
        enum:
          - 1
    AnyTypeContainsValue:
      contains:
        enum:
          - 1
    AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties:
      $schema: https://json-schema.org/draft/2020-12/schema
      properties:
        foo: {}
        bar: {}
      patternProperties:
        ^v: {}
      additionalProperties: false
  1. The schema in ArrayContainsValue.contains is given the property types = LinkedHashSet("number")
    This is incorrect because we see from the schema above that the schema there only defines an enum value and that anytype (type unset/null) is the correct definition.
  2. Type object is incorrectly set for AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties

Can the parser be updated to show that the type for this use case is null?

This bug was hit on the additionalProperties test case AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties when working on https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/pull/241

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 supplied OpenAPI 3.1 document, focusing on ArrayContainsValue.contains and AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties. Inspect the parser path exercised by the named additionalProperties test case; done means enum-only schemas retain an unset/null type and the additionalProperties=false schema is not assigned object.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.