openapi-to-graphql
openapi-to-graphql copied to clipboard
`required` field of definitions are not being respected while generating types
Describe the bug
required
field of definitions are not being respected while generating types
To Reproduce Steps to reproduce the behavior:
-
npm i -g openapi-to-graphql-cli
-
openapi-to-graphql file.yaml
--> file.yaml is as pasted below
swagger: "2.0"
info:
version: 1.1.0
title: Test server
basePath: /api/v1
host: localhost
paths:
/user/{id}:
get:
operationId: getUserId
tags:
- users
produces:
- application/json
parameters:
- name: id
in: path
description: User Id
required: true
type: integer
format: int64
responses:
200:
description: A User Response
schema:
$ref: "#/definitions/UserResponse"
definitions:
UserResponse:
type: object
required:
- userId
properties:
userId:
type: integer
format: int64
userName:
type: string
Expected behavior
"""The start of any query"""
type Query {
userResponse(
"""User Id"""
id: Float!
): UserResponse
}
type UserResponse {
userId: Float! <-----
userName: String
}
instead of
"""The start of any query"""
type Query {
userResponse(
"""User Id"""
id: Float!
): UserResponse
}
type UserResponse {
userId: Float
userName: String
}
@vinaybedre Thank you for the detailed issue with the OAS and expected/actual behavior. This is definitely a bug and should be working properly. I will take a look.
I replicated this error using CLI version 1.7.0, the latest version.
I also checked with the current build of the library and did not have this issue. I think by releasing a new version, which we are planning on doing either this or next week, we should be able to address this problem. Keep an eye out!