Skip to content

required field of definitions are not being respected while generating types #290

Open
@vinaybedre

Description

@vinaybedre

Describe the bug
required field of definitions are not being respected while generating types

To Reproduce
Steps to reproduce the behavior:

  1. npm i -g openapi-to-graphql-cli
  2. 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions