OpenAPITools / OpenAPITools/openapi-generator

[BUG] Input parameter of type array can not have default array

Open
#2,218 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

a input parameter of type array cannot take an array as default Parameter in Generator Version 3.3.4, when generating it it says:

-attribute paths.'/'(get).parameters.[orderSpecifier].schemas.default is not of type string``

openapi-generator version

3.3.4

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Customer API
  version: v1.0
tags:
- name: customers
  description: API to obtain customer information
servers:
- url: /admin/api/customers/v1
paths:
  /:
    get:
      summary: Get customers
      operationId: customers
      tags:
      - customers
      parameters:
      - in: query
        name: orderSpecifier
        description: takes an array of columns the results can be ordered by
        schema:
          type: array
          items:
            $ref: '#/components/schemas/CustomerOrderSpecifier'
          default: [CODE, NAME]
      responses:
        '200':
          description: A collection of customers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerCollection'
        '401':
          description: Forbidden. Login is required

components:
  schemas:
    CustomerCollection:
      description: A collection of Customers with response meta data
      properties:
        total:
          type: integer
          format: int64
        startAt:
          type: integer
          format: int64
        maxResults:
          type: integer
          format: int64
        customers:
          type: array
          items:
            $ref: '#/components/schemas/Customer'
      required:
      - total
      - startAt
      - maxResults
      - customers
    Customer:
      type: object
      description: Customer
      properties:
        code:
          type: string
          description: The customer code
        name:
          type: string
          description: The customer name
        logo:
          type: string
          description: URL of the customer image
      required:
      - code
      - name
    CustomerOrderSpecifier:
      type: string
      enum:
        - CODE
        - NAME
Command line used for generation

openapi-generator-maven-plugin

Steps to reproduce

add provided yml to the maven project. Add a for the yml file and let the plugin generate the sources

Related issues/PRs

couldn't find anything.

Suggest a fix

will look for it later

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 supplied OpenAPI YAML and reproduce the failure through the openapi-generator-maven-plugin using version 3.3.4. Trace the generator's handling of the array parameter default; done means generation accepts the array default without reporting that it must be a string.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.