swagger-api / swagger-api/swagger-parser

Default values inconsistencies with path file refs and path params

Open
#1,014 0 comments 0 reactions 1 assignee View on GitHub

@gracekarina is already working on this.

Since Feb 26, 2019.

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

Description

When using file refs with paths the parser doesn't fill parameter fields with default values. For example this ref configuration:

openapi: 3.0.0
info:
  version: 1.0.0
  title: Swagger Test
  license:
    name: MIT
servers:
  - url: /
paths:
  /api/pet/{petId}:
    $ref: "file.yaml"
get:
  summary: Info for a specific pet
  operationId: getById
  parameters:
    - name: petId
      in: path
      required: true
      description: The id of the pet to retrieve
      schema:
        type: integer
  responses:
    200:
      description: Expected response to a valid request

Generates this POJO:

class PathParameter {
    class Parameter {
        name: petId
        in: null
        description: The id of the pet to retrieve
        required: null
        deprecated: null
        allowEmptyValue: null
        style: null
        explode: null
        allowReserved: null
        schema: class IntegerSchema {
            class Schema {
                title: null
                multipleOf: null
                maximum: null
                exclusiveMaximum: null
                minimum: null
                exclusiveMinimum: null
                maxLength: null
                minLength: null
                pattern: null
                maxItems: null
                minItems: null
                uniqueItems: null
                maxProperties: null
                minProperties: null
                required: null
                type: null
                not: null
                properties: null
                additionalProperties: null
                description: null
                format: null
                $ref: null
                nullable: null
                readOnly: null
                writeOnly: null
                example: null
                externalDocs: null
                deprecated: null
                discriminator: null
                xml: null
            }
            type: integer
            format: null
            _default: null
            _enum: null
        }
        examples: null
        example: null
        content: null
        $ref: null
    }
    in: path
    required: true
}

While, with same spec but all inside same file, I receive this:

class PathParameter {
    class Parameter {
        name: petId
        in: null
        description: The id of the pet to retrieve
        required: null
        deprecated: null
        allowEmptyValue: null
        style: simple
        explode: false
        allowReserved: null
        schema: class IntegerSchema {
            class Schema {
                title: null
                multipleOf: null
                maximum: null
                exclusiveMaximum: null
                minimum: null
                exclusiveMinimum: null
                maxLength: null
                minLength: null
                pattern: null
                maxItems: null
                minItems: null
                uniqueItems: null
                maxProperties: null
                minProperties: null
                required: null
                type: null
                not: null
                properties: null
                additionalProperties: null
                description: null
                format: null
                $ref: null
                nullable: null
                readOnly: null
                writeOnly: null
                example: null
                externalDocs: null
                deprecated: null
                discriminator: null
                xml: null
            }
            type: integer
            format: int32
            _default: null
            _enum: null
        }
        examples: null
        example: null
        content: null
        $ref: null
    }
    in: path
    required: true
}

Note that style, explode, schema.format are inconsistent

I don't know if the same bug exists for remote http refs too. Swagger parser 2.0.8

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.