141 lines
3.2 KiB
Go
141 lines
3.2 KiB
Go
package apiTime
|
|
|
|
import "git.0x0001f346.de/andreas/api"
|
|
|
|
var tags []string = []string{"Time"}
|
|
|
|
func GetComponents() *api.Components {
|
|
components := &api.Components{
|
|
Schemas: map[string]*api.ComponentsSchema{
|
|
"CurrentTime": {
|
|
Properties: map[string]*api.ComponentsProperty{
|
|
"year": {
|
|
Type: "integer",
|
|
Description: "Year",
|
|
Format: "int64",
|
|
Example: 2020,
|
|
},
|
|
"month": {
|
|
Type: "integer",
|
|
Description: "Month",
|
|
Format: "int64",
|
|
Example: 12,
|
|
},
|
|
"day": {
|
|
Type: "integer",
|
|
Description: "Day",
|
|
Format: "int64",
|
|
Example: 13,
|
|
},
|
|
"hour": {
|
|
Type: "integer",
|
|
Description: "Hour of the day in range 0-24",
|
|
Format: "int64",
|
|
Example: 9,
|
|
},
|
|
"minute": {
|
|
Type: "integer",
|
|
Description: "Minute",
|
|
Format: "int64",
|
|
Example: 30,
|
|
},
|
|
"seconds": {
|
|
Type: "integer",
|
|
Description: "Second",
|
|
Format: "int64",
|
|
Example: 30,
|
|
},
|
|
"milliSeconds": {
|
|
Type: "integer",
|
|
Description: "Milliseconds",
|
|
Format: "int64",
|
|
Example: 123,
|
|
},
|
|
"dateTime": {
|
|
Type: "string",
|
|
Description: "Full date time",
|
|
Format: "date-time",
|
|
Example: "2020-12-13T09:30:30+01:00",
|
|
},
|
|
"date": {
|
|
Type: "string",
|
|
Description: "Date string",
|
|
Example: "13/12/2020",
|
|
},
|
|
"time": {
|
|
Type: "string",
|
|
Description: "Time string",
|
|
Example: "09:30",
|
|
},
|
|
"timeZone": {
|
|
Type: "string",
|
|
Description: "TimeZone of the result",
|
|
Example: "Europe/Berlin",
|
|
},
|
|
"dayOfWeek": {
|
|
Type: "string",
|
|
Description: "The day of the week",
|
|
Example: "Monday",
|
|
},
|
|
"dstActive": {
|
|
Type: "boolean",
|
|
Description: "Boolean describing whether DST is applied and active in that timezone",
|
|
Example: false,
|
|
},
|
|
},
|
|
AdditionalProperties: false,
|
|
},
|
|
},
|
|
}
|
|
|
|
return components
|
|
}
|
|
|
|
func GetPaths() map[string]*api.Path {
|
|
paths := map[string]*api.Path{
|
|
"/Time/current/zone": {
|
|
GET: &api.Method{
|
|
Function: TimeCurrentZone,
|
|
Tags: tags,
|
|
Summary: "Gets the current time of a time zone.",
|
|
Parameters: []*api.Parameters{
|
|
{
|
|
Name: "timeZone",
|
|
In: "query",
|
|
Description: "Full IANA time zone names.",
|
|
Schema: &api.ParametersSchema{
|
|
Type: "string",
|
|
},
|
|
Example: "Europe/Berlin",
|
|
AllowReserved: true,
|
|
},
|
|
},
|
|
Responses: map[int]*api.Response{
|
|
200: {
|
|
Description: "Current time",
|
|
Content: map[string]*api.ResponseContent{
|
|
"application/json": {
|
|
Schema: &api.ResponseSchema{
|
|
Ref: "#/components/schemas/CurrentTime",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
400: {
|
|
Description: "Error message",
|
|
Content: map[string]*api.ResponseContent{
|
|
"application/json": {
|
|
Schema: &api.ResponseSchema{
|
|
Type: "string",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return paths
|
|
}
|