Skip to content

Conversation

@P0lip
Copy link
Contributor

@P0lip P0lip commented May 15, 2019

No description provided.

@P0lip P0lip requested a review from casserni May 15, 2019 19:19
@P0lip P0lip force-pushed the feat/primary-type branch from 01aa4b9 to e16fd86 Compare May 15, 2019 19:20
@P0lip P0lip requested a review from marbemac May 15, 2019 19:20
annotations: getAnnotations(node),
enum: node.enum,
};
function getPrimaryType(node: JSONSchema4) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if type is ["object", "array"]

Copy link
Contributor

@casserni casserni May 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really the user should be using a oneOf like below, but if having both in type is valid json-schema we definitely need to support it

{
    "oneOf": [
        {"$ref": "#/definitions/singleObject"}, // plain object
        {
            "type": "array", // array of plain objects
            "items": {"$ref": "#/definitions/singleObject"}
        }
    ],
    "definitions": {
        "singleObject": {...}
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also means that if type is ["object", "array"] we need to infer that its a combiner type oneOf so it renders properly in the ui

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, shared the same concern here #17 (comment).
I'm not sure if displaying oneOf is safe though. To me, it sounds like a nice idea, but we'll need to make it reliable (transform the data correctly).
@marbemac, what's your take on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't worry about this use case until a customer complains about it.

@P0lip P0lip force-pushed the feat/primary-type branch from 1aafa31 to f6be200 Compare May 16, 2019 19:55
@P0lip P0lip merged commit f7df910 into master May 17, 2019
@P0lip P0lip deleted the feat/primary-type branch May 17, 2019 00:11
@stoplight-bot
Copy link
Collaborator

🎉 This PR is included in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants