diff --git a/elixir_example/input/account_controller_2.ex b/elixir_example/input/test_controller_apidoc.ex similarity index 51% rename from elixir_example/input/account_controller_2.ex rename to elixir_example/input/test_controller_apidoc.ex index 7a1fd5b8..1f5250b0 100644 --- a/elixir_example/input/account_controller_2.ex +++ b/elixir_example/input/test_controller_apidoc.ex @@ -5,10 +5,10 @@ defmodule BXApiExampleWeb.TestController do alias BXApiExample.Tests.Test @apidoc """ - @api {get} /test_entity/ List Tests + @api {get} /test_entity/ List @apiName ListTests - @apiGroup Tests - @apiVersion 0.31.0 + @apiGroup TestEntities + @apiVersion 0.8.15 @apiParam (Query Parameters) {Number} limit=500 Limit the number of returned elements @apiParam (Query Parameters) {String } [id] get a single id @@ -39,9 +39,9 @@ defmodule BXApiExampleWeb.TestController do @apidoc """ @api {post} /test_entity/ Create - @apiGroup Tests + @apiGroup TestEntities @apiName CreateTest - @apiVersion 0.31.0 + @apiVersion 0.8.15 @apiParam (Body) {String} name the name of the element @apiParam (Body) {String} tenant_id the tenant this element should belong to @@ -71,4 +71,64 @@ defmodule BXApiExampleWeb.TestController do |> render("show.json", test: result) end end + + @apidoc """ + @api {post} /example_entity/ Create + @apiGroup ExampleEntities + @apiName CreateTest + @apiVersion 0.8.15 + + @apiParam (Body) {String} name the name of the element + @apiParam (Body) {String} tenant_id the tenant this element should belong to + @apiParam (Body) {Object} settings={} a object of special settings for this element + + @apiSuccessExample Success-Response: + HTTP/1.1 201 Created + { + "id": "5fcc2352-aa5a-4ad2-8c98-f6af5f9b7637", + "name": "Test 183", + "tenant_id": "test", + "settings": { "foo": 1337 } + } + + @apiExample {curl} Curl: + curl -X POST -i http://api.example.com/api/example_entity -d '{ + "name": "Test 183", + "tenant_id": "test", + "settings": { "foo": 1337 } + }' + } + """ + def create(conn, test_params) do + with {:ok, %Test{} = result} <- Tests.create_Test(test_params) do + conn + |> put_status(:created) + |> render("show.json", test: result) + end + end + + @apidoc """ + @apiDefine MQTTExampleEntitiesData + @apiExample {mqtt} Example message: + { + "id": "5fcc2352-aa5a-4ad2-8c98-f6af5f9b7637", + "name": "Test 183", + "tenant_id": "test", + "settings": { "foo": 1337 } + } + """ + + @apidoc """ + @api {mqtt} tenant/:tenant_id/example_entity/create ExampleEntity Created + @apiGroup #MQTT-Messages + @apiName MQTT ExampleEntities Created + + @apiVersion 0.8.15 + @apiDescription MQTT Message after a new example entity was created + + @apiUse MQTTExampleEntitiesData + """ + defp get_topic(%{tenant_id: cid, id: _id}, "create") do + ["tenant/#{cid}/example_entity/create"] + end end diff --git a/elixir_example/input/account_controller_2_old.ex b/elixir_example/input/test_controller_comment.ex similarity index 100% rename from elixir_example/input/account_controller_2_old.ex rename to elixir_example/input/test_controller_comment.ex diff --git a/lib/core/languages/ex.js b/lib/core/languages/ex.js index b6d75162..ab2fbd99 100644 --- a/lib/core/languages/ex.js +++ b/lib/core/languages/ex.js @@ -13,7 +13,7 @@ const STANDARD_PARSER = { const OLD_PARSER = { docBlocksRegExp: /@apidoc\s+("{3})\uffff?(.+?)\uffff?(?:\s*)?("{3})+\s?/g, - inlineRegExp: /^@apidoc\s*\n/gm, + inlineRegExp: /^@apidoc\s*\n/g, }; module.exports = EX_TYPE === 'standard' ? STANDARD_PARSER : OLD_PARSER; diff --git a/template/index.html b/template/index.html index deabd2c1..500ad549 100644 --- a/template/index.html +++ b/template/index.html @@ -17,32 +17,38 @@ + + + +