396 lines
15 KiB
Plaintext
396 lines
15 KiB
Plaintext
{{! recursive partial used to expand type definition
|
|
HACK: Objects, Enums, Records and Arrays, which are used by reference
|
|
and defined outside the main units have to be handled explicitly.
|
|
All internal types have their Swagger-Typ defined. }}
|
|
{{<write-type}}{{#typeSwagger}}{{#Equals typeSwagger,typeSource}}{"$ref":"#/definitions/{{typeSwagger}}"}{{/Equals}}{{^Equals typeSwagger,typeSource}}{{typeSwagger}}{{/Equals}}{{/typeSwagger}}{{^typeSwagger}}{{#nestedSimpleArray}}{"type":"array","items":{{>write-type}}}{{/nestedSimpleArray}}{{/typeSwagger}}{{/write-type}}
|
|
|
|
{
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"description": "Generated by {{exeInfo}} using mORMot {{mORMotVersion}} at {{time}}",
|
|
"title": "{{root}} API{{#exeVersion}} {{.}}{{/exeVersion}}",
|
|
"version": "{{exeVersion}}"
|
|
},
|
|
"host": "{{host}}",
|
|
"basePath": "/{{root}}",
|
|
"tags": [
|
|
{{#orm}}
|
|
{
|
|
"name": "{{tableName}}",
|
|
"description": "ORM endpoint for {{root}}/{{tableName}} record"
|
|
}{{^-last}},{{/-last}}
|
|
{{/orm}}
|
|
{{#soa}}{{#hasorm}},{{/hasorm}}
|
|
{{#services}}
|
|
{
|
|
"name": "{{uri}}",
|
|
"description": {{#serviceDescription}}{{jsonQuote serviceDescription}}{{/serviceDescription}}{{^serviceDescription}}"SOA endpoint for {{root}}/{{uri}} service"{{/serviceDescription}}
|
|
}{{^-last}},{{/-last}}
|
|
{{/services}}
|
|
{{/soa}}
|
|
],
|
|
|
|
"definitions": {
|
|
{{#orm}}
|
|
"{{tableName}}": {
|
|
"type": "object",
|
|
"description": "ORM {{tableName}} record definition",
|
|
"properties": {
|
|
"ID":{"type":"integer","format":"int64"}{{#fields}},"{{name}}":{{typeSwagger}}{{/fields}}
|
|
}
|
|
},
|
|
{{/orm}}
|
|
{{#records}}
|
|
"{{name}}": {
|
|
"type": "object",
|
|
"description": "SOA {{name}} object DTO definition",
|
|
"properties": {
|
|
{{#fields}}
|
|
"{{propName}}": {{>write-type}}{{^-last}},{{/-last}}
|
|
{{/fields}}
|
|
}
|
|
},
|
|
|
|
{{/records}}
|
|
{{#arrays}}
|
|
"{{name}}": {
|
|
"type": "array",
|
|
"summary": "SOA {{name}} array DTO definition",
|
|
"items": {{>write-type}}
|
|
},
|
|
{{/arrays}}
|
|
{{#enumerates}}
|
|
"{{name}}": {
|
|
"type": "string",
|
|
"description": "SOA {{name}} enumeration DTO definition",
|
|
"enum": [
|
|
{{#values}}
|
|
"{{.}}"{{^-last}},{{/-last}}
|
|
{{/values}}
|
|
],
|
|
"required": true
|
|
},
|
|
|
|
{{/enumerates}}
|
|
"__error": {
|
|
"type": "object",
|
|
"description": "Generic error information",
|
|
"properties": {
|
|
"errorCode": {"type":"integer"},"errorText":{"type":"string"} }
|
|
}
|
|
},
|
|
"paths": {
|
|
{{#orm}}
|
|
|
|
"/{{tableName}}":{
|
|
"get": {
|
|
"tags": [
|
|
"{{tableName}}"
|
|
],
|
|
"summary": "query ORM fields values on {{tableName}}",
|
|
"description": "",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"parameters": [{
|
|
"name": "select",
|
|
"in": "query",
|
|
"description": "define returned fields of {{tableName}} query, set * to return all fields",
|
|
"required": true,
|
|
"type":"string"
|
|
},{
|
|
"name": "where",
|
|
"in": "query",
|
|
"description": "SELECT-like where condition for {{tableName}} query",
|
|
"required": false,
|
|
"type":"string"
|
|
},{
|
|
"name": "sort",
|
|
"in": "query",
|
|
"description": "order fields for {{tableName}} query",
|
|
"required": false,
|
|
"type":"string"
|
|
}],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{tableName}} not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "{{tableName}} not found"
|
|
},
|
|
"405": {
|
|
"description": "Unauthorized access to {{tableName}}"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/{{tableName}}/":{
|
|
"get": {
|
|
"tags": [
|
|
"{{tableName}}"
|
|
],
|
|
"summary": "retrieve all {{tableName}} ORM ids",
|
|
"description": "",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"parameters": [],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{tableName}} not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "{{tableName}} not found"
|
|
},
|
|
"405": {
|
|
"description": "Unauthorized access to {{tableName}}"
|
|
}
|
|
}
|
|
}
|
|
, "post": {
|
|
"tags": [
|
|
"{{tableName}}"
|
|
],
|
|
"summary": "creates a new {{tableName}} ORM record",
|
|
"description": "",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"parameters": [{
|
|
"name": "body",
|
|
"in": "body",
|
|
"description": "new {{tableName}} JSON object content",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
},
|
|
"required": true
|
|
}],
|
|
"responses": {
|
|
"201": {
|
|
"description": "successful operation",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{tableName}} not writable or not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "{{tableName}} not found"
|
|
},
|
|
"405": {
|
|
"description": "Unauthorized access to {{tableName}}"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/{{tableName}}/{id}":{
|
|
"get": {
|
|
"tags": [
|
|
"{{tableName}}"
|
|
],
|
|
"summary": "retrieve a {{tableName}} ORM record by id",
|
|
"description": "",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"parameters": [{
|
|
"name": "id",
|
|
"in": "path",
|
|
"description": "id to query {{tableName}}",
|
|
"required": true,
|
|
"type": "integer",
|
|
"format":"int64"
|
|
}],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{tableName}} not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "{{tableName}} not found"
|
|
},
|
|
"405": {
|
|
"description": "Unauthorized access to {{tableName}}"
|
|
}
|
|
}
|
|
}, "put": {
|
|
"tags": [
|
|
"{{tableName}}"
|
|
],
|
|
"summary": "change a {{tableName}} ORM record by id",
|
|
"description": "",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"parameters": [{
|
|
"name": "id",
|
|
"in": "path",
|
|
"description": "id to update {{tableName}}",
|
|
"required": true,
|
|
"type": "integer",
|
|
"format":"int64"
|
|
},{
|
|
"name": "body",
|
|
"in": "body",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
},
|
|
"description": "modified {{tableName}} JSON object content (partial fields accepted)",
|
|
"required": true
|
|
}],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{tableName}} not writable or not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "{{tableName}} not found"
|
|
},
|
|
"405": {
|
|
"description": "Unauthorized access to {{tableName}}"
|
|
}
|
|
}
|
|
},"delete": {
|
|
"tags": [
|
|
"{{tableName}}"
|
|
],
|
|
"summary": "remove a {{tableName}} ORM record by id",
|
|
"description": "",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"parameters": [{
|
|
"name": "id",
|
|
"in": "path",
|
|
"description": "id to delete {{tableName}}",
|
|
"required": true,
|
|
"type": "integer",
|
|
"format":"int64"
|
|
}],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"schema": {
|
|
"$ref": "#/definitions/{{tableName}}"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{tableName}} not writable or not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "{{tableName}} not found"
|
|
},
|
|
"405": {
|
|
"description": "Unauthorized access to {{tableName}}"
|
|
}
|
|
}
|
|
}
|
|
}{{^-last}},{{/-last}}
|
|
|
|
{{/orm}}
|
|
{{#soa}}{{#hasorm}},{{/hasorm}}{{#services}}
|
|
{{#methods}}
|
|
"/{{uri}}/{{methodName}}": {
|
|
"post": {
|
|
"description": {{jsonQuote methodDescription}},
|
|
"tags": [
|
|
"{{uri}}"
|
|
],
|
|
"parameters": [{
|
|
"in": "body",
|
|
"name": "body",
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": { {{#args}}{{#dirInput}}
|
|
"{{argName}}": {{>write-type}}{{commaInSingle}}{{/dirInput}}{{/args}}
|
|
}
|
|
}
|
|
}],
|
|
"responses": {
|
|
"200": {
|
|
"description": "{{uri}}.{{methodName}} executed - check returned content for any application-level error{{^resultAsJSONObjectWithoutResult}}\r\n **Warning: Swagger doesn't support untyped arrays, so isn't able to correctly define the response - please use rather *ResultAsJSONObjectWithoutResult* for a public API**{{/resultAsJSONObjectWithoutResult}}",
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
{{#resultAsJSONObjectWithoutResult}}
|
|
{{#args}} {{#dirOutput}}
|
|
"{{argName}}": {{>write-type}}{{#commaOutResult}},{{/commaOutResult}}
|
|
{{/dirOutput}}{{/args}}
|
|
{{/resultAsJSONObjectWithoutResult}}
|
|
{{^resultAsJSONObjectWithoutResult}}
|
|
"result": {
|
|
"type": "array",
|
|
"items": {"type":"string"}
|
|
}
|
|
{{/resultAsJSONObjectWithoutResult}}
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "{{uri}}.{{methodName}} execution not allowed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "{{uri}}.{{methodName}} not properly accessed",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
},
|
|
"406": {
|
|
"description": "{{uri}}.{{methodName}} execution failed - probably due to unexpected input",
|
|
"schema": {
|
|
"$ref": "#/definitions/__error"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}{{^-last}},{{/-last}}
|
|
{{/methods}}{{^-last}},{{/-last}}
|
|
|
|
{{/services}}{{/soa}}
|
|
}
|
|
}
|