Skip to content
Satish Sharma edited this page Jul 10, 2018 · 1 revision

Magic-Compose

Magic-Code framework works on the input JSON specified in the magic-compose format

!!! tip "Detailed Documentation"

Please reffer to below individual sections for detailed documentation.

* [Project Definition](./project)
* [Framework Configurations](./framework)
* [DTO/POJO and Entities](./dto_entities)
* [Creating Relationships](./relationships)
* [Exposed REST path's](./exposedpath)

**Sample Magic-Compose **

{
  "projectName": "MagicCode",
  "groupId": "com.magiccode.project",
  "artifactId": "myfirstmagiccode",
  "basePackage": "com.magiccode.project",
  "configs": {
    "portNumber": "8080",
    "loadBalancingEnabled": false,
    "cloudconfigEnabled": true,
    "serviceRegistrationEnabled": false,
    "securityEnabled": false,
    "actuatorEnabled": true,
    "devdb": "H2",
    "proddb": "MYSQL"
  },
  "entities": [
    {
      "name": "Order",
      "dto": true,
      "dbentity": false,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT"
        },
        {
          "name": "petId",
          "primaryColumn": false,
          "datatype": "INT"
        },
        {
          "name": "quantity",
          "primaryColumn": false,
          "datatype": "INT"
        },
        {
          "name": "shipDate",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "status",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "complete",
          "primaryColumn": false,
          "datatype": "BOOLEAN"
        }
      ]
    },
    {
      "name": "Category",
      "dto": true,
      "dbentity": false,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT"
        },
        {
          "name": "name",
          "primaryColumn": false,
          "datatype": "STRING"
        }
      ]
    },
    {
      "name": "User",
      "dto": true,
      "dbentity": false,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT"
        },
        {
          "name": "username",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "firstName",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "lastName",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "email",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "password",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "phone",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "userStatus",
          "primaryColumn": false,
          "datatype": "INT"
        }
      ]
    },
    {
      "name": "Tag",
      "dto": true,
      "dbentity": false,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT"
        },
        {
          "name": "name",
          "primaryColumn": false,
          "datatype": "STRING"
        }
      ]
    },
    {
      "name": "Pet",
      "dto": true,
      "dbentity": false,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT"
        },
        {
          "name": "category",
          "primaryColumn": false,
          "datatype": "OBJECT",
          "ref": "Category"
        },
        {
          "name": "name",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "photoUrls",
          "primaryColumn": false,
          "datatype": "ARRAY",
          "ref": "string"
        },
        {
          "name": "tags",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "status",
          "primaryColumn": false,
          "datatype": "STRING"
        }
      ]
    },
    {
      "name": "ApiResponse",
      "dto": true,
      "dbentity": false,
      "fields": [
        {
          "name": "code",
          "primaryColumn": false,
          "datatype": "INT"
        },
        {
          "name": "type",
          "primaryColumn": false,
          "datatype": "STRING"
        },
        {
          "name": "message",
          "primaryColumn": false,
          "datatype": "STRING"
        }
      ]
    },
    {
      "name": "Student",
      "idcolumn": "id",
      "dto": true,
      "dbentity": true,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT",
          "format": "INT32"
        },
        {
          "name": "firstName",
          "datatype": "STRING"
        }
      ]
    },
    {
      "name": "StudentDetails",
      "idcolumn": "id",
      "dto": true,
      "dbentity": true,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT",
          "format": "INT32"
        },
        {
          "name": "MiddleName",
          "datatype": "STRING"
        },
        {
          "name": "Email",
          "datatype": "STRING"
        },
        {
          "name": "lastName",
          "datatype": "STRING"
        }
      ]
    },
    {
      "name": "Address",
      "idcolumn": "id",
      "dto": true,
      "dbentity": true,
      "fields": [
        {
          "name": "id",
          "primaryColumn": true,
          "datatype": "INT",
          "format": "INT32"
        },
        {
          "name": "city",
          "datatype": "STRING"
        },
        {
          "name": "state",
          "datatype": "STRING"
        },
        {
          "name": "Country",
          "datatype": "STRING"
        }
      ]
    }
  ],
  "relationships": [
    {
      "relationType": "ONETOMANY",
      "bidirectional": true,
      "parent": "Student",
      "parentRelationshipName": "address",
      "parentJoinColumn": "address_id",
      "child": "Address",
      "childRelationshipName": "student",
      "childJoinColumn": "student_id1"
    },
    {
      "relationType": "ONETOONE",
      "bidirectional": true,
      "parent": "Student",
      "parentRelationshipName": "details",
      "parentJoinColumn": "details_id",
      "child": "StudentDetails",
      "childRelationshipName": "student",
      "childJoinColumn": "student_id2"
    }
  ],
  "tags": [
    "student",
    "book"
  ],
  "exposedPath": [
    {
      "tag": "student",
      "url": "/getstudent",
      "operation": "GET",
      "operationName": "getStudent",
      "parameters": [
        {
          "position": "HEADER",
          "name": "token",
          "type": "INT",
          "format": "INT32"
        },
        {
          "position": "HEADER",
          "name": "token2",
          "type": "INT",
          "format": "INT32"
        },
        {
          "position": "PATH",
          "name": "rollNumber",
          "type": "INT",
          "format": "INT32"
        },
        {
          "position": "BODY",
          "name": "student",
          "type": "OBJECT",
          "format": "ARRAY",
          "ref": "student"
        }
      ],
      "response": {
        "type": "OBJECT",
        "format": "ARRAY",
        "ref": "student"
      }
    },
    {
      "tag": "student",
      "url": "/addstudent",
      "operation": "POST",
      "operationName": "addStudent",
      "parameters": [
        {
          "position": "HEADER",
          "name": "token",
          "type": "INT",
          "format": "INT32"
        },
        {
          "position": "PATH",
          "name": "rollNumber",
          "type": "INT",
          "format": "INT32"
        },
        {
          "position": "BODY",
          "name": "student",
          "type": "OBJECT",
          "format": "ARRAY",
          "ref": "student"
        }
      ],
      "response": {
        "type": "OBJECT",
        "format": "OBJECT",
        "ref": "Student"
      }
    }
  ]
}

Clone this wiki locally