Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 8f8442c

Browse files
committed
Added Open API tags to the rest api.
1 parent 038eddc commit 8f8442c

File tree

5 files changed

+61
-42
lines changed

5 files changed

+61
-42
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.codeoverflow.chatoverflow.ui.web.rest
2+
3+
trait TagSupport {
4+
5+
protected def controllerTag: String
6+
7+
}
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
package org.codeoverflow.chatoverflow.ui.web.rest.config
22

33
import org.codeoverflow.chatoverflow.ui.web.rest.DTOs.{AuthKey, ConfigInfo, Password, ResultMessage}
4+
import org.codeoverflow.chatoverflow.ui.web.rest.TagSupport
45
import org.scalatra.swagger.SwaggerSupport
56
import org.scalatra.swagger.SwaggerSupportSyntax.OperationBuilder
67

7-
trait ConfigControllerDefinition extends SwaggerSupport {
8+
trait ConfigControllerDefinition extends SwaggerSupport with TagSupport {
89

910
val getConfig: OperationBuilder =
1011
(apiOperation[ConfigInfo]("getConfig")
1112
summary "Shows general information and settings."
12-
description "Shows API version and chat overflow startup settings.")
13-
13+
description "Shows API version and chat overflow startup settings."
14+
tags controllerTag)
1415
val postSave: OperationBuilder =
1516
(apiOperation[Boolean]("postSave")
1617
summary "Triggers the saving process of the framework manually (if loaded previously)."
17-
description "Triggers saving of credentials and configuration. Should not be needed manually.")
18-
18+
description "Triggers saving of credentials and configuration. Should not be needed manually."
19+
tags controllerTag)
1920
val postExit: OperationBuilder =
2021
(apiOperation[ResultMessage]("postExit")
2122
summary "Shuts the framework down."
2223
description "Shutdown the framework in the next second if a correct auth key is supplied."
24+
tags controllerTag
2325
parameter bodyParam[AuthKey]("body").description("Requires the run specific auth key."))
24-
25-
2626
val getLogin: OperationBuilder =
2727
(apiOperation[Boolean]("getLogin")
2828
summary "Returns if the framework is already loaded."
29-
description "Returns true, if the framework had been loaded previously with success.")
30-
29+
description "Returns true, if the framework had been loaded previously with success."
30+
tags controllerTag)
3131
val postLogin: OperationBuilder =
3232
(apiOperation[ResultMessage]("postLogin")
3333
summary "Logs in the the framework with the given password, loads config and credentials."
3434
description "Tries to decrypt the credentials using the provided password. If already loaded, does only return the communication auth key."
35+
tags controllerTag
3536
parameter bodyParam[Password]("body").description("Requires the user framework password. The auth key is based on this input."))
36-
3737
val getRegister: OperationBuilder =
3838
(apiOperation[Boolean]("getRegister")
3939
summary "Returns if a credentials file has been created and thus a specific password been registered."
40-
description "Returns true, if the credentials file (with set password) already exists.")
41-
40+
description "Returns true, if the credentials file (with set password) already exists."
41+
tags controllerTag)
4242
val postRegister: OperationBuilder =
4343
(apiOperation[ResultMessage]("postRegister")
4444
summary "Registers the user with the given password. Can only be called if there is no credentials file."
4545
description "Creates a credentials file with the given password. Acts like post(login) after this (returning an auth key)."
46+
tags controllerTag
4647
parameter bodyParam[Password]("body").description("Requires the user framework password. The auth key is based on this input."))
4748

49+
override def controllerTag: String = "config"
4850

4951
override protected def applicationDescription: String = "Handles configuration and information retrieval."
5052
}

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/connector/ConnectorControllerDefinition.scala

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,71 @@ package org.codeoverflow.chatoverflow.ui.web.rest.connector
22

33
import org.codeoverflow.chatoverflow.connector.ConnectorKey
44
import org.codeoverflow.chatoverflow.ui.web.rest.DTOs._
5+
import org.codeoverflow.chatoverflow.ui.web.rest.TagSupport
56
import org.scalatra.swagger.SwaggerSupport
67
import org.scalatra.swagger.SwaggerSupportSyntax.OperationBuilder
78

8-
trait ConnectorControllerDefinition extends SwaggerSupport {
9+
trait ConnectorControllerDefinition extends SwaggerSupport with TagSupport {
910

1011
val getConnectors: OperationBuilder =
1112
(apiOperation[ConnectorKey]("getConnectors")
1213
summary "Shows all connector keys."
13-
description "Shows the unique keys (connector type and source Identifier) of all connectors.")
14-
14+
description "Shows the unique keys (connector type and source Identifier) of all connectors."
15+
tags controllerTag)
1516
val getConnector: OperationBuilder =
1617
(apiOperation[ConnectorDetails]("getConnector")
1718
summary "Shows all information of a specific connector."
1819
description "Besides unique key, shows additional information like required and optional credentials. "
20+
tags controllerTag
1921
parameter pathParam[String]("sourceIdentifier").description("The (connector unique) identifier of e.g. a account to connect to")
2022
parameter pathParam[String]("qualifiedConnectorType").description("The fully qualified type of the connector."))
21-
2223
val postConnector: OperationBuilder =
2324
(apiOperation[ResultMessage]("postConnector")
2425
summary "Creates a new connector."
2526
description "Creates a connector with given sourceIdentifier and connector type."
27+
tags controllerTag
2628
parameter bodyParam[ConnectorRef]("body").description("Requires platform specific source identifier and connector type."))
27-
2829
val deleteConnector: OperationBuilder =
2930
(apiOperation[ResultMessage]("deleteConnector")
3031
summary "Deletes a specific connector."
3132
description "Deletes the connector specified by identifier and unique type string."
33+
tags controllerTag
3234
parameter pathParam[String]("sourceIdentifier").description("The (connector unique) identifier of e.g. a account to connect to")
3335
parameter pathParam[String]("qualifiedConnectorType").description("The fully qualified type of the connector."))
34-
3536
val getCredentials: OperationBuilder =
3637
(apiOperation[ConnectorDetails]("getCredentials")
3738
summary "Shows all credentials for a specified connector."
3839
description "Shows required and optional credentials. Note, that the user has to be logged in and the values are encrypted using the auth key. "
40+
tags controllerTag
3941
parameter pathParam[String]("sourceIdentifier").description("The (connector unique) identifier of e.g. a account to connect to")
4042
parameter pathParam[String]("qualifiedConnectorType").description("The fully qualified type of the connector."))
41-
4243
val getCredentialsEntry: OperationBuilder =
4344
(apiOperation[CredentialsEntry]("getCredentialsEntry")
4445
summary "Shows a specific credentials entry of a specific connector."
4546
description "Shows one credentials entry if existent. Note, that the user has to be logged in and the value is encrypted using the auth key. "
47+
tags controllerTag
4648
parameter pathParam[String]("sourceIdentifier").description("The (connector unique) identifier of e.g. a account to connect to")
4749
parameter pathParam[String]("qualifiedConnectorType").description("The fully qualified type of the connector.")
4850
parameter pathParam[String]("key").description("The key of the credentials entry."))
49-
5051
val postCredentialsEntry: OperationBuilder =
5152
(apiOperation[ResultMessage]("postCredentialsEntry")
5253
summary "Creates a new credentials entry."
5354
description "Creates a new credentials entry with given parameters for a given connector. Note that only required & optional keys can be added."
55+
tags controllerTag
5456
parameter pathParam[String]("sourceIdentifier").description("The (connector unique) identifier of e.g. a account to connect to")
5557
parameter pathParam[String]("qualifiedConnectorType").description("The fully qualified type of the connector.")
5658
parameter bodyParam[EncryptedKeyValuePair]("body").description("Requires a key-value pair. The value must be encrypted using the auth key."))
57-
5859
val deleteCredentialsEntry: OperationBuilder =
5960
(apiOperation[ResultMessage]("deleteCredentialsEntry")
6061
summary "Deletes a specific credentials entry."
6162
description "Deletes a specific credentials entry of a given connector, if possible."
63+
tags controllerTag
6264
parameter pathParam[String]("sourceIdentifier").description("The (connector unique) identifier of e.g. a account to connect to")
6365
parameter pathParam[String]("qualifiedConnectorType").description("The fully qualified type of the connector.")
6466
parameter pathParam[String]("key").description("The key of the credentials entry.")
6567
parameter bodyParam[AuthKey]("body").description("Requires the client auth key since this is a sensible operation."))
6668

69+
override def controllerTag: String = "connector"
6770

6871
override protected def applicationDescription: String = "Handles platform connectors."
6972

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,78 @@
11
package org.codeoverflow.chatoverflow.ui.web.rest.plugin
22

33
import org.codeoverflow.chatoverflow.ui.web.rest.DTOs._
4+
import org.codeoverflow.chatoverflow.ui.web.rest.TagSupport
45
import org.scalatra.swagger.SwaggerSupport
56
import org.scalatra.swagger.SwaggerSupportSyntax.OperationBuilder
67

7-
trait PluginInstanceControllerDefinition extends SwaggerSupport {
8+
trait PluginInstanceControllerDefinition extends SwaggerSupport with TagSupport {
89

910
val getInstances: OperationBuilder =
1011
(apiOperation[List[PluginInstance]]("getInstances")
1112
summary "Shows all plugin instances."
12-
description "Shows the name, plugin information and requirement keys of all plugin instances.")
13-
13+
description "Shows the name, plugin information and requirement keys of all plugin instances."
14+
tags controllerTag)
1415
val getInstance: OperationBuilder =
1516
(apiOperation[PluginInstance]("getInstance")
1617
summary "Shows a plugin instance."
1718
description "Shows the name, plugin information and requirement keys of a specified plugin instance."
19+
tags controllerTag
1820
parameter pathParam[String]("instanceName").description("The name of the plugin instance."))
19-
2021
val getRequirements: OperationBuilder =
2122
(apiOperation[List[Requirement]]("getRequirements")
2223
summary "Shows all requirements of a plugin instance."
2324
description "Shows state, name and type of all requirements of a specified plugin instance."
25+
tags controllerTag
2426
parameter pathParam[String]("instanceName").description("The name of the plugin instance."))
25-
2627
val getRequirement: OperationBuilder =
2728
(apiOperation[Requirement]("getRequirement")
2829
summary "Shows a specific requirement of a plugin instance."
2930
description "Shows state, name and type of one specific requirement of a specified plugin instance."
31+
tags controllerTag
3032
parameter pathParam[String]("instanceName").description("The name of the plugin instance.")
3133
parameter pathParam[String]("requirementID").description("The unique id of the requirement."))
32-
3334
val putRequirement: OperationBuilder =
3435
(apiOperation[ResultMessage]("putRequirement")
3536
summary "Changes the value and type of a specific requirement."
3637
description "Changes the value (serialized content) and the target type of a requirement of one instance."
38+
tags controllerTag
3739
parameter pathParam[String]("instanceName").description("The name of the plugin instance.")
3840
parameter pathParam[String]("requirementID").description("The unique id of the requirement.")
3941
parameter bodyParam[RequirementInfo]("body").description("Requires target type and serialized content."))
40-
4142
val getLog: OperationBuilder =
4243
(apiOperation[List[String]]("getLog")
4344
summary "Shows the log of a plugin instance."
4445
description "Shows all (or the newest) log messages of a specified plugin instance."
46+
tags controllerTag
4547
parameter pathParam[String]("instanceName").description("The name of the plugin instance.")
4648
parameter queryParam[Option[String]]("startIndex").description("The start index of the message stream").optional)
47-
4849
val postInstance: OperationBuilder =
4950
(apiOperation[ResultMessage]("postInstance")
5051
summary "Creates a new plugin instance."
5152
description "Creates a new plugin instance with given name and plugin type."
53+
tags controllerTag
5254
parameter bodyParam[PluginInstanceRef]("body").description("Requires new instance name and PluginType (name and author)."))
53-
5455
val deleteInstance: OperationBuilder =
5556
(apiOperation[PluginInstance]("deleteInstance")
5657
summary "Removes a plugin instance."
5758
description "Removes a plugin instance specified by its name, if possible."
59+
tags controllerTag
5860
parameter pathParam[String]("instanceName").description("The name of the plugin instance."))
59-
6061
val startInstance: OperationBuilder =
6162
(apiOperation[ResultMessage]("startInstance")
6263
summary "Starts a specific plugin instance."
6364
description "Starts a specific plugin instance if possible."
65+
tags controllerTag
6466
parameter bodyParam[PluginInstanceName]("body").description("Requires the name of the plugin instance."))
65-
6667
val stopInstance: OperationBuilder =
6768
(apiOperation[ResultMessage]("stopInstance")
6869
summary "Stops a specific plugin instance."
6970
description "Requires the stop of a specified plugin instance. This can take up to one loop interval."
71+
tags controllerTag
7072
parameter bodyParam[PluginInstanceName]("body").description("Requires the name of the plugin instance."))
7173

74+
override def controllerTag: String = "instance"
75+
7276
override protected def applicationDescription: String = "Handles plugin instances and requirements."
7377

7478
}

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/types/TypesControllerDefinition.scala

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
package org.codeoverflow.chatoverflow.ui.web.rest.types
22

33
import org.codeoverflow.chatoverflow.ui.web.rest.DTOs._
4+
import org.codeoverflow.chatoverflow.ui.web.rest.TagSupport
45
import org.scalatra.swagger.SwaggerSupport
56
import org.scalatra.swagger.SwaggerSupportSyntax.OperationBuilder
67

7-
trait TypesControllerDefinition extends SwaggerSupport {
8+
trait TypesControllerDefinition extends SwaggerSupport with TagSupport {
89

910
val getPluginType: OperationBuilder =
1011
(apiOperation[List[PluginType]]("getPlugin")
1112
summary "Shows all possible plugin types."
12-
description "Shows name, author, api version and state of all possible plugin types.")
13-
13+
description "Shows name, author, api version and state of all possible plugin types."
14+
tags controllerTag)
1415
val getRequirementType: OperationBuilder =
1516
(apiOperation[RequirementTypes]("getRequirementType")
1617
summary "Shows all possible requirement types."
17-
description "Shows the fully qualified api type strings of all requirement types, grouped by input/output/parameter.")
18-
18+
description "Shows the fully qualified api type strings of all requirement types, grouped by input/output/parameter."
19+
tags controllerTag)
1920
val getConnectorType: OperationBuilder =
2021
(apiOperation[List[String]]("getConnectorType")
2122
summary "Shows all possible connector types."
22-
description "Shows the fully qualified type strings of all connectors.")
23-
23+
description "Shows the fully qualified type strings of all connectors."
24+
tags controllerTag)
2425
val getTypes: OperationBuilder =
2526
(apiOperation[Types]("getTypes")
2627
summary "Shows all possible types of plugins, requirements and connectors."
27-
description "Shows all possible types of plugins, requirements and connectors.")
28-
28+
description "Shows all possible types of plugins, requirements and connectors."
29+
tags controllerTag)
2930
val getReqImpl: OperationBuilder =
3031
(apiOperation[APIAndSpecificType]("getReqImpl")
3132
summary "Shows all implementations of a specified api type."
3233
description "Shows the specific type (implementation) and the connector of a specified api type."
34+
tags controllerTag
3335
parameter queryParam[String]("api").description("The fully qualified api type string"))
34-
3536
val getSubTypes: OperationBuilder =
3637
(apiOperation[SubTypes]("getSubTypes")
3738
summary "Shows all sub types of a specified api type."
3839
description "Shows all sub types (sub typing api interfaces) of a specified api type."
40+
tags controllerTag
3941
parameter queryParam[String]("api").description("The fully qualified api type string"))
4042

43+
override def controllerTag: String = "type"
4144

4245
override protected def applicationDescription: String = "Handles requirement, plugin and controller types."
4346

0 commit comments

Comments
 (0)