Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postman Collection — fields incorrectly marked as required #116

Open
XVincentX opened this issue Aug 31, 2020 · 4 comments
Open

Postman Collection — fields incorrectly marked as required #116

XVincentX opened this issue Aug 31, 2020 · 4 comments
Labels
t/bug Something isn't working team/platinum-falcons Team Platinum Falcons

Comments

@XVincentX
Copy link
Contributor

The following example object

{
  "result": [
    {
      "id": "1",
      "cat": {
        "catfield1": {},
        "catfield2": {
          "name": "text"
        }
      },
      "dog": {}
    },
    {
      "id": "2",
      "cat": {
        "catfield1": {
          "code": "text",
          "name": "text"
        },
        "catfield2": {
          "name": "text"
        }
      },
      "dog": {
        "dogfield1": "text",
        "dogfield2": "text"
      },
      "mouse": {
        "mousefield1": "text"
      }
    }
  ]

Marks dogfield1 and dogfield2 as required, although they only appear once in the array, and not on all of them

@karol-maciaszek
Copy link
Contributor

json-schema-generator indeed has issue with creating schema from arrays: krg7880/json-schema-generator#30.

I investigated quicktype and it generates schema correctly. Here is a relevant output:

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "$ref": "#/definitions/Welcome",
    "definitions": {
        "Welcome": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "result": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Result"
                    }
                }
            },
            "required": [
                "result"
            ],
            "title": "Welcome"
        },
        "Result": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "id": {
                    "type": "string",
                    "format": "integer"
                },
                "cat": {
                    "$ref": "#/definitions/Cat"
                },
                "dog": {
                    "$ref": "#/definitions/Dog"
                },
                "mouse": {
                    "$ref": "#/definitions/Mouse"
                }
            },
            "required": [
                "cat",
                "dog",
                "id"
            ],
            "title": "Result"
        },
        "Cat": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "catfield1": {
                    "$ref": "#/definitions/Catfield1"
                },
                "catfield2": {
                    "$ref": "#/definitions/Catfield2"
                }
            },
            "required": [
                "catfield1",
                "catfield2"
            ],
            "title": "Cat"
        },
        "Catfield1": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "code": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            },
            "required": [],
            "title": "Catfield1"
        },
        "Catfield2": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "name": {
                    "type": "string"
                }
            },
            "required": [
                "name"
            ],
            "title": "Catfield2"
        },
        "Dog": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "dogfield1": {
                    "type": "string"
                },
                "dogfield2": {
                    "type": "string"
                }
            },
            "required": [],
            "title": "Dog"
        },
        "Mouse": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "mousefield1": {
                    "type": "string"
                }
            },
            "required": [
                "mousefield1"
            ],
            "title": "Mouse"
        }
    }
}

Unfortunately, quicktype has two drawbacks:

  1. it weights 1.8mb
  2. it has async API, while our interface in http-spec is synchronous

@XVincentX

@lottamus
Copy link
Contributor

lottamus commented Sep 2, 2020

@karol-maciaszek @XVincentX yeah quicktype is massive for our needs lol https://bundlephobia.com/[email protected]

How much work to fix that issue in our fork of json-schema-generator? I don't think json-schema-generator is being maintained anymore 🤔

@XVincentX
Copy link
Contributor Author

@karol-maciaszek will investigate on the matter. I do agree that QuickType is really too heavy and it's not worth (especially if it's solely because of Postman Collection support).

@lottamus
Copy link
Contributor

lottamus commented Sep 8, 2020

Might be good to chat with @marcelltoth too since he's working on integrating json-schema-generator into Studio, so maybe it makes sense to integrate our fork instead? https://github.com/stoplightio/platform-internal/pull/4273

@lottamus lottamus added this to the 2020-10-13 milestone Oct 13, 2020
@chohmann chohmann removed this from the 2020-10-13 milestone Nov 3, 2020
@raleigh04 raleigh04 added t/bug Something isn't working and removed bug Something isn't working labels May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working team/platinum-falcons Team Platinum Falcons
Projects
None yet
Development

No branches or pull requests

5 participants