Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more examples to openapi.yaml #7

Merged
merged 1 commit into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions api/message_bus/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ paths:
The connection will be upgraded to a WebSocket connection and the client will receive actions as they are triggered.

components:

securitySchemes:
access_token:
type: apiKey
Expand Down Expand Up @@ -296,7 +295,7 @@ components:
items:
type: string
example: "local-storage:disk:added,local-storage:disk:removed"

ActionName:
name: name
in: path
Expand Down Expand Up @@ -463,7 +462,7 @@ components:
name:
type: string
description: property name
example: "local-storage:path"
example: "local-storage:vendor"

EventType:
type: object
Expand All @@ -487,31 +486,62 @@ components:
type: array
items:
$ref: "#/components/schemas/PropertyType"
example:
- "local-storage:vendor"
- "local-storage:model"
- "local-storage:uuid"
- "casaos-ui:type"
- "casaos-ui:title"
- "casaos-ui:icon-1"
- "casaos-ui:message-1"

Property:
type: object
properties:
name:
type: string
description: property name
example: "local-storage:vendor"
value:
type: string
description: property value
example: "SanDisk"

Event:
type: object
required:
- "sourceID"
- "name"
- "properties"
properties:
sourceID:
type: string
description: associated source id
example: "local-storage"
name:
type: string
description: event name
example: "local-storage:disk:added"
properties:
type: array
description: event properties
items:
$ref: "#/components/schemas/Property"
example:
- name: local-storage:vendor
value: SanDisk
- name: local-storage:model
value: Cruzer
- name: local-storage:uuid
value: 442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7
- name: casaos-ui:type
value: notification-style-2
- name: casaos-ui:title
value: "New disk found"
- name: casaos-ui:icon-1
value: casaos-icon-disk
- name: casaos-ui:message-1
value: "A new disk, SanDisk Cruzer, is added."
timestamp:
type: string
description: timestamp this event took place
Expand Down Expand Up @@ -546,9 +576,11 @@ components:
sourceID:
type: string
description: associated source id
example: "local-storage"
name:
type: string
description: action name
example: "local-storage:disk:format"
properties:
type: array
description: action properties
Expand Down
6 changes: 3 additions & 3 deletions route/adapter/in/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func EventAdapter(event codegen.Event) model.Event {
properties := make([]model.Property, 0)
for _, property := range *event.Properties {
for _, property := range event.Properties {
properties = append(properties, PropertyAdapter(property))
}

Expand All @@ -17,8 +17,8 @@ func EventAdapter(event codegen.Event) model.Event {
}

return model.Event{
SourceID: *event.SourceID,
Name: *event.Name,
SourceID: event.SourceID,
Name: event.Name,
Properties: properties,
Timestamp: timestamp,
}
Expand Down
6 changes: 3 additions & 3 deletions route/adapter/out/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func EventAdapter(event model.Event) codegen.Event {
}

return codegen.Event{
SourceID: &event.SourceID,
Name: &event.Name,
Properties: &properties,
SourceID: event.SourceID,
Name: event.Name,
Properties: properties,
Timestamp: utils.Ptr(time.Unix(event.Timestamp, 0)),
}
}
6 changes: 3 additions & 3 deletions route/api_route_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func (r *APIRoute) PublishEvent(ctx echo.Context, sourceID codegen.SourceID, nam
}

event := codegen.Event{
SourceID: &sourceID,
Name: &name,
Properties: &properties,
SourceID: sourceID,
Name: name,
Properties: properties,
Timestamp: utils.Ptr(time.Now()),
}

Expand Down