Creating Model class with schema file of Json-api standard


#1

I'm working on Java rest web services where in one of the requirement, i'm supposed to call third party api which uses json:api standard Request and responses. I have a schema from which i'm trying to generate Model java classes(POJO) for serializing & de-serializing purpose but i couldn't find any resources to auto-generate the class files. Since the schema is more than 1500 lines including many child specs; writing model class manually is time consuming. Since i'm new to json:api couldn't able to find the right solution to address this problem, requesting suggestions on how to proceed.

Thanks in advance.

Below is the one part of schema.

{
  "data": [{
    "attributes": {
      "name": "attachments",
      "specification": {
        "attributes": {
          "description": {
            "type": "string"
          },
          "document": {
            "type": "object",
            "attributes": {
              "href": {
                "type": "string",
                "format": "uri"
              },
              "name": {
                "type": "string"
              },
              "media-type": {
                "type": "string"
              }
            },
            "required": ["media-type", "href"],
            "name": "document"
          },
          "created-at": {
            "type": "string",
            "format": "date-time"
          },
          "last-modified-at": {
            "type": "string",
            "format": "date-time"
          },
          "created-by": {
            "type": "object",
            "attributes": {
              "formatted-name": {
                "type": "string"
              },
              "a-id": {
                "type": "string"
              }
            },
            "required": ["a-id"],
            "name": "a"
          },
          "valid-for": {
            "type": "object",
            "attributes": {
              "start-datetime": {
                "type": "string",
                "format": "date-time"
              },
              "end-datetime": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": ["start-datetime"],
            "name": "valid-for-datetime"
          },
          "last-modified-by": {
            "type": "object",
            "attributes": {
              "formatted-name": {
                "type": "string"
              },
              "a-id": {
                "type": "string"
              }
            },
            "required": ["a-id"],
            "name": "a"
          }
        },
        "functions": {
          "update": {
            "parameters": {
              "attributes": {
                "last-modified-by": {
                  "type": "object",
                  "attributes": {
                    "formatted-name": {
                      "type": "string"
                    },
                    "a-id": {
                      "type": "string"
                    }
                  },
                  "required": ["a-id"],
                  "name": "a"
                },
                "description": {
                  "type": "string"
                },
                "document": {
                  "type": "object",
                  "attributes": {
                    "href": {
                      "type": "string",
                      "format": "uri"
                    },
                    "name": {
                      "type": "string"
                    },
                    "media-type": {
                      "type": "string"
                    }
                  },
                  "required": ["media-type", "href"],
                  "name": "document"
                },
                "valid-for": {
                  "type": "object",
                  "attributes": {
                    "start-datetime": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "end-datetime": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": ["start-datetime"],
                  "name": "valid-for-datetime"
                }
              },
              "relationships": {
                "instance": {
                  "included": false,
                  "relation": "to-one",
                  "resource": ["attachments"]
                }
              },
              "required": ["last-modified-by", "instance"]
            },
            "resource-restrictions": {

            }
          },
          "create": {
            "parameters": {
              "attributes": {

              },
              "relationships": {
                "new-instance": {
                  "included": true,
                  "relation": "to-one",
                  "resource": ["attachments"]
                }
              },
              "required": ["new-instance"]
            },
            "resource-restrictions": {
              "attachments": {
                "read-only": ["created-at", "last-modified-at", "last-modified-by"],
                "required": ["document", "valid-for", "created-by", "note"]
              }
            }
          }
        },
        "methods": {
          "GET": {
            "filters": [],
            "required": ["created-at", "created-by", "document", "valid-for", "note"]
          }
        },
        "relationships": {
          "note": {
            "relation": "to-one",
            "resource": ["notes"]
          }
        }
      }
    },
    "relationships": {
      "interface": {
        "links": {
          "related": "/api/resource-schemas/xxx/interface"
        },
        "data": {
          "id": "xxx",
          "type": "interface-schemas"
        }
      }
    },
    "links": {
      "self": "/api/resource-schemas/xxx"
    },
    "id": "xxx",
    "type": "resource-schemas"
  },
  "links": {
    "self": "/api/interface-schemas/xxx/resources"
  }
]

#2

What format is this schema? If you need to generate POJOs for your domain I would suggest you look there, the spec doesn’t really have anything to do with the payload representations directly.