📝 Update generated documentation with new Models

This commit contains the new documentation for the API endpoints that
will now use the newly generated models that describe their reponse
correctly
This commit is contained in:
Florian Beisel 2024-01-18 00:15:14 +01:00
parent f0118ab8ea
commit c08de78984
Signed by: florian
GPG Key ID: 79ECA2E54996FF4D
3 changed files with 205 additions and 71 deletions

View File

@ -52,7 +52,7 @@ const docTemplate = `{
"200": {
"description": "Hostname",
"schema": {
"type": "string"
"$ref": "#/definitions/models.SimpleHostnameResponse"
}
}
}
@ -85,7 +85,7 @@ const docTemplate = `{
"200": {
"description": "Hostname",
"schema": {
"type": "string"
"$ref": "#/definitions/models.SimpleHostnameResponse"
}
}
}
@ -148,37 +148,25 @@ const docTemplate = `{
"200": {
"description": "Successfully authenticated, JWT token returned",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.TokenResponse"
}
},
"400": {
"description": "Invalid request body",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.ErrorResponse"
}
},
"401": {
"description": "Invalid login credentials",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
@ -211,9 +199,12 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "Hostname",
"description": "An array of responses",
"schema": {
"type": "json"
"type": "array",
"items": {
"$ref": "#/definitions/models.Hostname"
}
}
}
}
@ -253,9 +244,9 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "Hostname",
"description": "A single response object",
"schema": {
"type": "json"
"$ref": "#/definitions/models.Hostname"
}
}
}
@ -295,7 +286,7 @@ const docTemplate = `{
"200": {
"description": "Hostname",
"schema": {
"type": "json"
"$ref": "#/definitions/models.SimpleHostnameResponse"
}
}
}
@ -303,14 +294,72 @@ const docTemplate = `{
}
},
"definitions": {
"models.ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"models.Hostname": {
"description": "Model of the Hostname as it is represented in the database",
"type": "object",
"properties": {
"Category": {
"description": "Category / Rule that was used when generating the hostname",
"type": "string",
"example": "notebook"
},
"Created_at": {
"description": "Creation Time of the entry",
"type": "string",
"example": "2024-01-16T12:53:59Z"
},
"Hostname": {
"description": "Generated hostname",
"type": "string",
"example": "ISEHENNB0009"
},
"Id": {
"description": "Internal ID of the Hostname within the database",
"type": "integer",
"example": 25
},
"Parameters": {
"description": "Parameter object of rule specific attributes, see rule.* models",
"type": "object",
"additionalProperties": true
}
}
},
"models.LoginCredentials": {
"description": "User account information used in the login process with Username and password",
"type": "object",
"properties": {
"password": {
"Password": {
"type": "string"
},
"username": {
"Username": {
"type": "string"
}
}
},
"models.SimpleHostnameResponse": {
"description": "Model of the Hostname as returned by POST endpoint",
"type": "object",
"properties": {
"Hostname": {
"description": "Name of the newly generated host",
"type": "string"
}
}
},
"models.TokenResponse": {
"description": "Model returned after successful login",
"type": "object",
"properties": {
"token": {
"type": "string"
}
}

View File

@ -46,7 +46,7 @@
"200": {
"description": "Hostname",
"schema": {
"type": "string"
"$ref": "#/definitions/models.SimpleHostnameResponse"
}
}
}
@ -79,7 +79,7 @@
"200": {
"description": "Hostname",
"schema": {
"type": "string"
"$ref": "#/definitions/models.SimpleHostnameResponse"
}
}
}
@ -142,37 +142,25 @@
"200": {
"description": "Successfully authenticated, JWT token returned",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.TokenResponse"
}
},
"400": {
"description": "Invalid request body",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.ErrorResponse"
}
},
"401": {
"description": "Invalid login credentials",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
@ -205,9 +193,12 @@
],
"responses": {
"200": {
"description": "Hostname",
"description": "An array of responses",
"schema": {
"type": "json"
"type": "array",
"items": {
"$ref": "#/definitions/models.Hostname"
}
}
}
}
@ -247,9 +238,9 @@
],
"responses": {
"200": {
"description": "Hostname",
"description": "A single response object",
"schema": {
"type": "json"
"$ref": "#/definitions/models.Hostname"
}
}
}
@ -289,7 +280,7 @@
"200": {
"description": "Hostname",
"schema": {
"type": "json"
"$ref": "#/definitions/models.SimpleHostnameResponse"
}
}
}
@ -297,14 +288,72 @@
}
},
"definitions": {
"models.ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"models.Hostname": {
"description": "Model of the Hostname as it is represented in the database",
"type": "object",
"properties": {
"Category": {
"description": "Category / Rule that was used when generating the hostname",
"type": "string",
"example": "notebook"
},
"Created_at": {
"description": "Creation Time of the entry",
"type": "string",
"example": "2024-01-16T12:53:59Z"
},
"Hostname": {
"description": "Generated hostname",
"type": "string",
"example": "ISEHENNB0009"
},
"Id": {
"description": "Internal ID of the Hostname within the database",
"type": "integer",
"example": 25
},
"Parameters": {
"description": "Parameter object of rule specific attributes, see rule.* models",
"type": "object",
"additionalProperties": true
}
}
},
"models.LoginCredentials": {
"description": "User account information used in the login process with Username and password",
"type": "object",
"properties": {
"password": {
"Password": {
"type": "string"
},
"username": {
"Username": {
"type": "string"
}
}
},
"models.SimpleHostnameResponse": {
"description": "Model of the Hostname as returned by POST endpoint",
"type": "object",
"properties": {
"Hostname": {
"description": "Name of the newly generated host",
"type": "string"
}
}
},
"models.TokenResponse": {
"description": "Model returned after successful login",
"type": "object",
"properties": {
"token": {
"type": "string"
}
}

View File

@ -1,12 +1,54 @@
basePath: /api/v1
definitions:
models.ErrorResponse:
properties:
error:
type: string
type: object
models.Hostname:
description: Model of the Hostname as it is represented in the database
properties:
Category:
description: Category / Rule that was used when generating the hostname
example: notebook
type: string
Created_at:
description: Creation Time of the entry
example: "2024-01-16T12:53:59Z"
type: string
Hostname:
description: Generated hostname
example: ISEHENNB0009
type: string
Id:
description: Internal ID of the Hostname within the database
example: 25
type: integer
Parameters:
additionalProperties: true
description: Parameter object of rule specific attributes, see rule.* models
type: object
type: object
models.LoginCredentials:
description: User account information used in the login process with Username
and password
properties:
password:
Password:
type: string
username:
Username:
type: string
type: object
models.SimpleHostnameResponse:
description: Model of the Hostname as returned by POST endpoint
properties:
Hostname:
description: Name of the newly generated host
type: string
type: object
models.TokenResponse:
description: Model returned after successful login
properties:
token:
type: string
type: object
rules.NotebookRuleInput:
@ -43,9 +85,11 @@ paths:
- application/json
responses:
"200":
description: Hostname
description: An array of responses
schema:
type: json
items:
$ref: '#/definitions/models.Hostname'
type: array
security:
- Bearer: []
summary: Return a list of hosts and their details filtered by category
@ -72,7 +116,7 @@ paths:
"200":
description: Hostname
schema:
type: json
$ref: '#/definitions/models.SimpleHostnameResponse'
security:
- Bearer: []
summary: Delete a hostname from the database
@ -96,9 +140,9 @@ paths:
- application/json
responses:
"200":
description: Hostname
description: A single response object
schema:
type: json
$ref: '#/definitions/models.Hostname'
security:
- Bearer: []
summary: Return a single hostname by Category and Name
@ -123,7 +167,7 @@ paths:
"200":
description: Hostname
schema:
type: string
$ref: '#/definitions/models.SimpleHostnameResponse'
summary: Generate hostname for category "notebook"
tags:
- Generating Hostnames
@ -145,7 +189,7 @@ paths:
"200":
description: Hostname
schema:
type: string
$ref: '#/definitions/models.SimpleHostnameResponse'
summary: Update hostname for category "notebook"
tags:
- Generating Hostnames
@ -185,27 +229,19 @@ paths:
"200":
description: Successfully authenticated, JWT token returned
schema:
additionalProperties:
type: string
type: object
$ref: '#/definitions/models.TokenResponse'
"400":
description: Invalid request body
schema:
additionalProperties:
type: string
type: object
$ref: '#/definitions/models.ErrorResponse'
"401":
description: Invalid login credentials
schema:
additionalProperties:
type: string
type: object
$ref: '#/definitions/models.ErrorResponse'
"500":
description: Internal server error
schema:
additionalProperties:
type: string
type: object
$ref: '#/definitions/models.ErrorResponse'
summary: User login
tags:
- Authentication