[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
- Copy/paste the yaml above into a test.yml
- 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]
}