JSON Hypermedia Api with forms and links

后端 未结 5 1517
南方客
南方客 2020-12-25 15:08

I am in the early stages of planning a REST api, and I would like for it to adhere to the HATEOAS constraint of REST. But I would also like to provide a JSON format. So my q

5条回答
  •  独厮守ぢ
    2020-12-25 15:47

    I have been working on an API, using JSON Hyper Schema. You can browse aroun, and even register, login and do some actions. Check it out, here: http://api.psprt.com

    [EDIT] See my latest stuff here: www.passportedu.com https://github.com/bpanahij/HypermediaServer https://github.com/bpanahij/client-schema.json

    I also open sourced the API code: https://github.com/bpanahij/passportedu_schema

    Feel free to take a look, borrow, and comment.

    JSON Hyper Schema (See Also JSON-Schema) has a way to specify forms, through the properties member:

    {
    "id": "/api/v1",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "PassportEDU API",
    "name": "PassportEDU API",
    "type": "object",
    "description": "Bringing global students together with global schools.",
    "links": [
       {
          "title": "Log In",
          "rel": "authenticate",
          "href": "/api/v1/authenticate",
          "method": "POST",
          "properties": {
            "username": {
              "title": "Your username",
              "description": "Your email address or username",
              "type": "string"
            },
            "password": {
              "title": "Your password",
              "description": "Your password",
              "type": "password"
            }
          },
          "required": ["username", "password"]
       }
       ]
    }
    

提交回复
热议问题