Open yakupbeyoglu opened 1 month ago
Example json can be found at https://github.com/yakupbeyoglu/ForgeAPI/issues/2#issue-2540546808
{}
[]
"table"
"posts"
Field Name: Verify that the "fields" field is an array.
"fields"
Field Object Structure:
"name"
"type"
"bigIncrements"
"string"
"text"
"unsignedBigInteger"
Additional Properties (if applicable):
"length"
"foreign"
"references"
"onDelete"
"cascade"
"relations"
"belongsTo"
"model"
"User"
"foreignKey"
"routes"
"method"
"GET"
"POST"
"uri"
"action"
"index"
"store"
"custom_sql"
"authorization"
"public"
"authorization_groups"
"middleware"
"auth"
It can also { "name": "auth", "routes":"/posts/*" } // This means all routes need auth.
"role"
"admin"
"description"
Syntax Analysis Checklist for JSON Structure
Example json can be found at https://github.com/yakupbeyoglu/ForgeAPI/issues/2#issue-2540546808
1. Overall Structure
{}
) and not an array ([]
) or a primitive value (e.g., string, number).2. Table Definition
"table"
field exists and is a string."table"
is a valid table name (e.g.,"posts"
).3. Fields Array
Field Name: Verify that the
"fields"
field is an array.Field Object Structure:
"fields"
array must be an object with at least"name"
and"type"
fields."name"
should be a string representing the column name."type"
should be a string specifying the data type (e.g.,"bigIncrements"
,"string"
,"text"
,"unsignedBigInteger"
).Additional Properties (if applicable):
"string"
type fields, check if"length"
is present and is a number."foreign"
type fields, ensure it is an object with valid properties:"table"
should be a string."references"
should be a string."onDelete"
, '"onUpdate"' should be a valid action string (e.g.,"cascade"
).4. Relations Array
"relations"
field is an array."relations"
array must be an object with the following fields:"type"
: a string indicating the type of relation (e.g.,"belongsTo"
)."model"
: a string representing the related model name (e.g.,"User"
)."foreignKey"
: a string representing the foreign key field.5. Routes Array
"routes"
field is an array."routes"
array must be an object with at least the following fields:"method"
: a string indicating the HTTP method (e.g.,"GET"
,"POST"
)."uri"
: a string representing the route URI."action"
: a string representing the action to be taken (e.g.,"index"
,"store"
)."custom_sql"
: if present, it should be a string containing valid SQL."authorization"
: if present, it should be a valid authorization type (e.g.,"public"
)."authorization_groups"
: if present, it should be an array of strings representing role names.6. Middleware Array
"middleware"
field is an array."middleware"
array must be an object with:"name"
: a string indicating the middleware name (e.g.,"auth"
)."routes"
: an array of strings representing the routes to which this middleware applies.7. Authorization Groups
"authorization_groups"
field is an array."authorization_groups"
array must be an object with:"role"
: a string representing the role name (e.g.,"admin"
)."description"
: a string describing the role.Validation Steps