OpenAPITools / OpenAPITools/openapi-generator

[REQ] Reduce the elements in the generated example arrays

Open
#12,651 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

For a request body like:

Personalization:
      required:
        - to
      properties:
        to:
          type: array
          minItems: 1
          maxItems: 1000
          items:
            $ref: '#/components/schemas/EmailAddress'
        cc:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/EmailAddress'
        bcc:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/EmailAddress'

The generated curl example includes five elements in each array. It is kind of unwieldy, using the max of minItems or 1 might look better

curl -X POST \
 -H "Accept: application/json" \
 -H "Content-Type: application/json" \
 "https://www.example.com" \
 -d '{
  "personalizations" : [ {
    "cc" : [ {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    } ],
    "bcc" : [ {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    } ],
    "to" : [ {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    }, {
      "name" : "name",
      "email" : "email"
    } ]
    } ] }

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

The issue names no files, tests, or entry points. Trace the request-body example generation path for OpenAPI array schemas, then run the relevant generator tests or reproduce the curl example; done means generated arrays use the requested smaller element count without affecting other examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.