Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5684
Closed
Open
Issue created Mar 23, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [graphql-nodejs-express-server] generates improper model for arrays

Created by: rdecarreau

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

My spec has an array in it, when I run the generator, the model for the array is an empty type.

openapi-generator version

CLI version 4.2.3

OpenAPI declaration file content or url
openapi: '3.0.0'
info:
  title: My API
  description: This is a test
  version: 0.1.1

paths:
  /someArray:
    get:
      summary: Returns an array
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SomeArray'
components:
  schema:
    SomeArray:
      type: array
      items:
          type: integer
Command line used for generation

java -jar codegen-cli.jar generate -i test.yml -g graphql-nodejs-express-server -o /out/graphql-nodejs-express-server --generate-alias-as-model

Steps to reproduce
  1. Copy/paste the yaml above into a test.yml
  2. Call the command above via command line
Related issues/PRs

NA

Suggest a fix

This is a tough one. OpenAPI doesn't provide a name element for array types, but GraphQL requires that each property be named (sensibly). Maybe the generator can use the type name? Actual

type SomeArray {
}

input SomeArrayInput {
}

Expected

type SomeArray {
  someArray: [Int]
}

input SomeArrayInput {
    someArray: [Int]
}
Assignee
Assign to
Time tracking