OpenAPITools / OpenAPITools/openapi-generator
[BUG][NODEJS] graphql-nodejs-express-server with PetStore, only one type named "User"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When generating and running the PetStore demo with graphql-nodejs-express-server you get the error:
Error: There can be only one type named "User".
Field "User.id" can only be defined once.
Field "User.firstName" can only be defined once.
Field "User.lastName" can only be defined once.
This errors and prevents the server from running.
openapi-generator version
"@openapitools/openapi-generator-cli": "^1.0.15-4.3.1"
OpenAPI declaration file content or url
Using: https://petstore.swagger.io/v2/swagger.yaml
definitions:
User:
type: "object"
properties:
id:
type: "integer"
format: "int64"
username:
type: "string"
firstName:
type: "string"
lastName:
type: "string"
email:
type: "string"
password:
type: "string"
phone:
type: "string"
userStatus:
type: "integer"
format: "int32"
description: "User Status"
xml:
name: "User"
Command line used for generation
npx @openapitools/openapi-generator-cli generate -i https://petstore.swagger.io/v2/swagger.yaml -g graphql-nodejs-express-server -o .
Steps to reproduce
npm install @openapitools/openapi-generator-cli
npx @openapitools/openapi-generator-cli generate -i https://petstore.swagger.io/v2/swagger.yaml -g graphql-nodejs-express-server -o .
cd openapi3graphql-server
npm install
npm start
Related issues/PRs
not found any similar
Suggest a fix
Changing the petstore.yaml User type to User2 fixes the issue
User:toUser2:name: "User"toname: "User2"#/definitions/Userto#/definitions/User2
It seems to be a conflict with the name type User is it a reserved type?
EDIT: Also just noticed it creates a subfolder openapi3graphql-server when the other generators do not
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the documented graphql-nodejs-express-server generation command with the PetStore swagger.yaml, then inspect the generated schema and server startup output for duplicate User definitions. Trace where the User type is emitted and verify the generated server starts without duplicate-type errors while preserving the PetStore models and references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100