Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Output "default" MSON as "default" JSON Schema #424

Closed
jmatsushita opened this issue Nov 2, 2016 · 3 comments
Closed

Output "default" MSON as "default" JSON Schema #424

jmatsushita opened this issue Nov 2, 2016 · 3 comments

Comments

@jmatsushita
Copy link

Hi there,

Currently MSON defaults are only emitted as application/json content and not as application/schema+json which reminds me of #392.

Related to our use apiaryio/mson#70 use case I would like to be able to export MSON Defaults as described here, for example:

 - deleted: false (boolean, required, default)

as JSON Schema defaults that are part of the JSON Schema Validation spec in this way:

    "deleted": {
      "type": "boolean",
      "default": false
    }

Which will enable us to deal with the Boolean Gotcha for the form generator we use and avoid empty required boolean checkboxes to be seen as undefined and be seen as false instead.

image

@kylef kylef added bug and removed bug labels Nov 2, 2016
@kylef
Copy link
Member

kylef commented Nov 2, 2016

Looking at the MSON Spec, it states:

Indicates Values for Member Types as a nested Markdown list with (multi-line) text are defaults.
...
A default Type Attribute MUST NOT be used in the Type Definition of a Property Member Declaration.

Which from what I understand, means that default can only be used with member types such as enum, and array. It does seem that default is supported in JSON Schemas for array and enum member types.

However, I do not see any reason why we should limit default to just these types, it may also make sense to support default in an objects property as you've shown in your message.

@zdne I would love to hear your feedback here, perhaps you might have a reason default was designed to only be for member types only that I'm not aware of.

@pksunkara
Copy link
Contributor

+ a: pavan
    + Default: pksunkara

That is valid as far as I know.

kylef added a commit that referenced this issue Nov 18, 2016
pksunkara pushed a commit that referenced this issue Nov 23, 2016
pksunkara pushed a commit that referenced this issue Nov 24, 2016
kylef pushed a commit that referenced this issue Jul 7, 2017
@miduddin
Copy link

Sorry for commenting on an old issue. Apparently the issue still exist on latest drafter version (v4.0.0), although i've tried v3.2.0 and it seems to work just fine there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants