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

Allow for greater flexibility for defining properties in a JSON Collection #131

Open
DreamingInBinary opened this issue Mar 27, 2018 · 2 comments

Comments

@DreamingInBinary
Copy link
Contributor

DreamingInBinary commented Mar 27, 2018

Take this simple JSON response:

{
    "success": true|false,
    "error": {
        "message": "string",
        "code": "string",
        "details": {
            "error": "string"
        }
    }
}

As it stands now with Plank, you can define the success property easily within one model, but the dictionaries in the response leave you with either having to use a Map type (which more or less kills the power of Plank for me as I don't want to do something like errorModel[@"details"][@"error"]) or create another model to reference for error and details. Creating another model gives me the type safety I'm after, but at the same time it's also time consuming and a bit overkill.

It'd be create if we define properties by keying them via the dictionary like Mantle allows, something like this for the example above:

{
"id": "errorDetails.json",
"title": "errorDetails",
"description" : "Schema definition of Reply Error",
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
	"success" : { "type": "boolean" },
	"error.message" : { "type": "string" },
	"error.code" : { "type": "string" },
            "error.details.error": { "type": "string" }
}

}

Unless I'm missing something, I don't think that's possible today with Plank. Either way, keep up the great work!

@rahul-malik
Copy link
Collaborator

Definitely not possible with plank today but this is approaching a more generalized way to have simpler concrete types defined alongside the parent type

This does seem convenient but if we did this I would imagine we could just inline the definition of the new schema vs putting it in a separate file. Thoughts?

@ay8s
Copy link
Contributor

ay8s commented Apr 24, 2018

@rahul-malik That'd be super useful, we have a few cases already where we could simplify things a bunch if you could inline the definition.

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

No branches or pull requests

3 participants