apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.65k stars 2.14k forks source link

Schema section #112

Closed rgregg closed 10 years ago

rgregg commented 10 years ago

Are there more details about what content goes in the Schema section in a Payload? The documentation just says "Specifies a validation schema for the HTTP message-body" but doesn't provide any examples.

honzajavorek commented 10 years ago

You can find more details at http://support.apiary.io/knowledgebase/articles/147279-json-schema-validation. Example:

# Note [/notes/{id}]

## Retrieve one Note [GET]
+ Request

    ... (Schema can be used here too to validate sent data, if any. E.g. when POSTing JSON encoded form-data)

+ Response (application/json)

    + Body

            { "id": 2, "title": "Pick-up posters from post-office" }

    + Schema

            {
                "type": "object",
                "required": false,
                "properties": {
                    "title": {
                        "type": ["string", "null"],
                        "required": false
                    },
                    "id": {
                        "type": "number",
                        "required": true
                    }
                }
            }
zdne commented 10 years ago

@rgregg Hope the question has been answered – If still uncertain, please ask at Stack Overflow http://stackoverflow.com/questions/tagged/apiblueprint using the apiblueprint tag. We will take care of any questions there. Thanks.

gondo commented 9 years ago

@zdne wouldn't it be better to update the documentation rather than point people to stackoverflow?

zdne commented 9 years ago

@gondo you are indeed correct! @kylef is working on a new set of tutorials that will definitely cover this. Thanks for pointing this one out.

gondo commented 9 years ago

@zdne cool.

in the meantime, this might help someone, or someone might help me :) http://stackoverflow.com/questions/28221984/how-to-create-nested-schema

zdne commented 9 years ago

Thanks for sharing! :+1: