Skip to end of banner
Go to start of banner

Spike: SPIKE: Data Import Component: Investigate an approach to move backend file upload functionality into a separate java library

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

IN PROGRESS

Spike goals:

  • check if it is possible to define a RAML file without any endpoints just to declare traits and imports, the goal is to generate DTOs and reusable traits
  • check if it is possible to extend or inherit JSON schemas. if not demonstrate how to include or wrap JSON schemas.

Let's assume we have following *raml* fileĀ 

library.raml
#%RAML 1.0

title: Book Library API
version: v0.1

documentation:
  - title: Introduction
    content: Automated access to books
  - title: Licensing
    content: Please respect copyrights on our books.

types:
  book: !include bookParent.json
  bookCollection: !include bookCollection.json
  errors: !include raml-util/schemas/errors.schema

traits:
  language: !include raml-util/traits/language.raml

resourceTypes:
  collection: !include raml-util/rtypes/collection.raml
  collection-item: !include raml-util/rtypes/item-collection.raml

/books:
  description: The collection of library books
  type:
    collection:
      schemaCollection: bookCollection
      schemaItem: book
      exampleCollection: !include examples/bookCollection.sample
      exampleItem: !include examples/book.sample

The definition of the book collection looks similar to other collections used in project

bookCollection.json
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "Collection of books",
  "properties": {
    "books": {
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "bookChild.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "books",
    "totalRecords"
  ]
}

Here, for the reference field I have used "bookChild.json" file, which is a childĀ  of other json file

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "A book parent",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "description": "The name of the book",
      "type": "string"
    },
    "author": {
      "description": "The author of the book",
      "type": "string"
    },
    "metadata": {
      "description": "Metadata about creation and changes, provided by the server (client should not provide)",
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "author"
  ]
}


{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "A book child",
  "additionalProperties": true,
  "extends" : {
    "$ref" : "bookParent.json"
  },
  "properties": {
    "id": {
      "type": "string"
    },
    "publisher": {
      "description": "The publisher of the book",
      "type": "string"
    }
  }
}





  • No labels