Description
The CommandableSwaggerDocument class allows you to generate Swagger code that describes created REST API methods and their parameters.
Constructors
NewCommandableSwaggerDocument
Creates a new instance of the service.
NewCommandableSwaggerDocument(baseRoute string, config *cconf.ConfigParams, commands []ccomands.ICommand) *CommandableSwaggerDocument
- baseRoute: string - base route of the service
- config: *cconf.ConfigParams - configuration parameters
- commands: []ccomands.ICommand - list of commmands.
Fields
Methods
GetCorrelationId
GetCorrelationId method returns CorrelationId from request
(c *HttpEndpoint) GetCorrelationId(req *http.Request) string
- req: *http.Request - an HTTP request
- returns: string - correlation_id or empty string
GetSpaces
Returns a string with spaces.
(c *CommandableSwaggerDocument) GetSpaces(length int) string
- length: int - determines the length of the string with spaces.
- returns: string - string containing spaces.
ToString
Returns string with Swagger code that describe service methods.
(c *CommandableSwaggerDocument) ToString() string
- returns: string - string with the API information.
typeToString
Returns a string with the type name.
(c *CommandableSwaggerDocument) typeToString(tp cconv.TypeCode) string
- tp: cconv.TypeCode - type (e.g. Integer)
- returns: string - name of the type (e.g. ‘integer’)
writeArrayItem
Writes an array item to Swagger code.
(c *CommandableSwaggerDocument) writeArrayItem(indent int, name string, isObjectItem bool)
- indent: int - number of spaces
- name: string - item’s name
- isObjectItem: bool - True is the item is an object. false otherwise.
writeAsObject
Adds a property and its value.
(c *CommandableSwaggerDocument) writeAsObject(indent int, name string, value interface{})
- indent: int - number of spaces
- name: string - name of the property
- value: interface{} - value of the property
writeAsString
Adds a string property and its string value.
(c *CommandableSwaggerDocument) writeAsString(indent int, name string, value interface{})
- indent: int - number of spaces
- name: string - name of the property
- value: string - value of the property
WriteData
Adds data to the Swagger code.
(c *CommandableSwaggerDocument) WriteData(indent int, data map[string]interface{})
- indent: int - number of spaces
- name: string - name
- data: map[string]interface{} - data to be added
WriteName
Write a property or object name.
(c *CommandableSwaggerDocument) WriteName(indent int, name string)
- indent: int - number of spaces
- name: string - string with added identation