mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-18 13:24:15 +00:00
fix: add omitempty and generate swagger json with required fields
This commit is contained in:
parent
7a9b9919ef
commit
40f299deff
@ -142,7 +142,7 @@ COPY src/plugin_loader.go /tmp/signal-cli-rest-api-src/
|
|||||||
|
|
||||||
# build signal-cli-rest-api
|
# build signal-cli-rest-api
|
||||||
RUN ls -la /tmp/signal-cli-rest-api-src
|
RUN ls -la /tmp/signal-cli-rest-api-src
|
||||||
RUN cd /tmp/signal-cli-rest-api-src && ${GOPATH}/bin/swag init
|
RUN cd /tmp/signal-cli-rest-api-src && ${GOPATH}/bin/swag init --requiredByDefault
|
||||||
RUN cd /tmp/signal-cli-rest-api-src && go build -o signal-cli-rest-api main.go
|
RUN cd /tmp/signal-cli-rest-api-src && go build -o signal-cli-rest-api main.go
|
||||||
RUN cd /tmp/signal-cli-rest-api-src && go test ./client -v && go test ./utils -v
|
RUN cd /tmp/signal-cli-rest-api-src && go test ./client -v && go test ./utils -v
|
||||||
|
|
||||||
|
|||||||
@ -34,32 +34,32 @@ const (
|
|||||||
|
|
||||||
type UpdateContactRequest struct {
|
type UpdateContactRequest struct {
|
||||||
Recipient string `json:"recipient"`
|
Recipient string `json:"recipient"`
|
||||||
Name *string `json:"name"`
|
Name *string `json:"name,omitempty"`
|
||||||
ExpirationInSeconds *int `json:"expiration_in_seconds"`
|
ExpirationInSeconds *int `json:"expiration_in_seconds,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateGroupRequest struct {
|
type CreateGroupRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Members []string `json:"members"`
|
Members []string `json:"members"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description,omitempty"`
|
||||||
Permissions ds.GroupPermissions `json:"permissions"`
|
Permissions ds.GroupPermissions `json:"permissions,omitempty"`
|
||||||
GroupLinkState string `json:"group_link" enums:"disabled,enabled,enabled-with-approval"`
|
GroupLinkState string `json:"group_link,omitempty" enums:"disabled,enabled,enabled-with-approval"`
|
||||||
ExpirationTime *int `json:"expiration_time"`
|
ExpirationTime *int `json:"expiration_time,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateGroupRequest struct {
|
type UpdateGroupRequest struct {
|
||||||
Base64Avatar *string `json:"base64_avatar"`
|
Base64Avatar *string `json:"base64_avatar,omitempty"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description,omitempty"`
|
||||||
Name *string `json:"name"`
|
Name *string `json:"name,omitempty"`
|
||||||
ExpirationTime *int `json:"expiration_time"`
|
ExpirationTime *int `json:"expiration_time,omitempty"`
|
||||||
GroupLinkState *string `json:"group_link" enums:"disabled,enabled,enabled-with-approval"`
|
GroupLinkState *string `json:"group_link,omitempty" enums:"disabled,enabled,enabled-with-approval"`
|
||||||
Permissions *ds.GroupPermissions `json:"permissions"`
|
Permissions *ds.GroupPermissions `json:"permissions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PinMessageInGroupRequest struct {
|
type PinMessageInGroupRequest struct {
|
||||||
TargetAuthor string `json:"target_author"`
|
TargetAuthor string `json:"target_author"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
Duration *int `json:"duration"`
|
Duration *int `json:"duration,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnpinMessageInGroupRequest struct {
|
type UnpinMessageInGroupRequest struct {
|
||||||
@ -84,17 +84,17 @@ type Configuration struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RegisterNumberRequest struct {
|
type RegisterNumberRequest struct {
|
||||||
UseVoice bool `json:"use_voice"`
|
UseVoice bool `json:"use_voice,omitempty"`
|
||||||
Captcha string `json:"captcha"`
|
Captcha string `json:"captcha,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnregisterNumberRequest struct {
|
type UnregisterNumberRequest struct {
|
||||||
DeleteAccount bool `json:"delete_account" example:"false"`
|
DeleteAccount bool `json:"delete_account,omitempty" example:"false"`
|
||||||
DeleteLocalData bool `json:"delete_local_data" example:"false"`
|
DeleteLocalData bool `json:"delete_local_data,omitempty" example:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerifyNumberSettings struct {
|
type VerifyNumberSettings struct {
|
||||||
Pin string `json:"pin"`
|
Pin string `json:"pin,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Reaction struct {
|
type Reaction struct {
|
||||||
@ -114,27 +114,27 @@ type SendMessageV1 struct {
|
|||||||
Number string `json:"number"`
|
Number string `json:"number"`
|
||||||
Recipients []string `json:"recipients"`
|
Recipients []string `json:"recipients"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Base64Attachment string `json:"base64_attachment" example:"'<BASE64 ENCODED DATA>' OR 'data:<MIME-TYPE>;base64,<BASE64 ENCODED DATA>' OR 'data:<MIME-TYPE>;filename=<FILENAME>;base64,<BASE64 ENCODED DATA>'"`
|
Base64Attachment string `json:"base64_attachment,omitempty" example:"'<BASE64 ENCODED DATA>' OR 'data:<MIME-TYPE>;base64,<BASE64 ENCODED DATA>' OR 'data:<MIME-TYPE>;filename=<FILENAME>;base64,<BASE64 ENCODED DATA>'"`
|
||||||
IsGroup bool `json:"is_group"`
|
IsGroup bool `json:"is_group,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendMessageV2 struct {
|
type SendMessageV2 struct {
|
||||||
Number string `json:"number"`
|
Number string `json:"number"`
|
||||||
Recipients []string `json:"recipients"`
|
Recipients []string `json:"recipients"`
|
||||||
Recipient string `json:"recipient" swaggerignore:"true"` //some REST API consumers (like the Synology NAS) do not support an array as recipients, so we provide this string parameter here as backup. In order to not confuse anyone, the parameter won't be exposed in the Swagger UI (most users are fine with the recipients parameter).
|
Recipient string `json:"recipient,omitempty" swaggerignore:"true"` //some REST API consumers (like the Synology NAS) do not support an array as recipients, so we provide this string parameter here as backup. In order to not confuse anyone, the parameter won't be exposed in the Swagger UI (most users are fine with the recipients parameter).
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Base64Attachments []string `json:"base64_attachments" example:"<BASE64 ENCODED DATA>,data:<MIME-TYPE>;base64<comma><BASE64 ENCODED DATA>,data:<MIME-TYPE>;filename=<FILENAME>;base64<comma><BASE64 ENCODED DATA>"`
|
Base64Attachments []string `json:"base64_attachments,omitempty" example:"<BASE64 ENCODED DATA>,data:<MIME-TYPE>;base64<comma><BASE64 ENCODED DATA>,data:<MIME-TYPE>;filename=<FILENAME>;base64<comma><BASE64 ENCODED DATA>"`
|
||||||
Sticker string `json:"sticker"`
|
Sticker string `json:"sticker,omitempty"`
|
||||||
Mentions []ds.MessageMention `json:"mentions"`
|
Mentions []ds.MessageMention `json:"mentions,omitempty"`
|
||||||
QuoteTimestamp *int64 `json:"quote_timestamp"`
|
QuoteTimestamp *int64 `json:"quote_timestamp,omitempty"`
|
||||||
QuoteAuthor *string `json:"quote_author"`
|
QuoteAuthor *string `json:"quote_author,omitempty"`
|
||||||
QuoteMessage *string `json:"quote_message"`
|
QuoteMessage *string `json:"quote_message,omitempty"`
|
||||||
QuoteMentions []ds.MessageMention `json:"quote_mentions"`
|
QuoteMentions []ds.MessageMention `json:"quote_mentions,omitempty"`
|
||||||
TextMode *string `json:"text_mode" enums:"normal,styled"`
|
TextMode *string `json:"text_mode,omitempty" enums:"normal,styled"`
|
||||||
EditTimestamp *int64 `json:"edit_timestamp"`
|
EditTimestamp *int64 `json:"edit_timestamp,omitempty"`
|
||||||
NotifySelf *bool `json:"notify_self"`
|
NotifySelf *bool `json:"notify_self,omitempty"`
|
||||||
LinkPreview *ds.LinkPreviewType `json:"link_preview"`
|
LinkPreview *ds.LinkPreviewType `json:"link_preview,omitempty"`
|
||||||
ViewOnce *bool `json:"view_once"`
|
ViewOnce *bool `json:"view_once,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypingIndicatorRequest struct {
|
type TypingIndicatorRequest struct {
|
||||||
@ -157,13 +157,13 @@ type CreateGroupResponse struct {
|
|||||||
|
|
||||||
type UpdateProfileRequest struct {
|
type UpdateProfileRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Base64Avatar string `json:"base64_avatar"`
|
Base64Avatar string `json:"base64_avatar,omitempty"`
|
||||||
About *string `json:"about"`
|
About *string `json:"about,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrustIdentityRequest struct {
|
type TrustIdentityRequest struct {
|
||||||
VerifiedSafetyNumber *string `json:"verified_safety_number"`
|
VerifiedSafetyNumber *string `json:"verified_safety_number,omitempty"`
|
||||||
TrustAllKnownKeys *bool `json:"trust_all_known_keys" example:"false"`
|
TrustAllKnownKeys *bool `json:"trust_all_known_keys,omitempty" example:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendMessageResponse struct {
|
type SendMessageResponse struct {
|
||||||
@ -203,8 +203,8 @@ type RateLimitChallengeRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateAccountSettingsRequest struct {
|
type UpdateAccountSettingsRequest struct {
|
||||||
DiscoverableByNumber *bool `json:"discoverable_by_number"`
|
DiscoverableByNumber *bool `json:"discoverable_by_number,omitempty"`
|
||||||
ShareNumber *bool `json:"share_number"`
|
ShareNumber *bool `json:"share_number,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetUsernameRequest struct {
|
type SetUsernameRequest struct {
|
||||||
@ -226,7 +226,7 @@ type RemoteDeleteRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DeleteLocalAccountDataRequest struct {
|
type DeleteLocalAccountDataRequest struct {
|
||||||
IgnoreRegistered bool `json:"ignore_registered" example:"false"`
|
IgnoreRegistered bool `json:"ignore_registered,omitempty" example:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeviceLinkUriResponse struct {
|
type DeviceLinkUriResponse struct {
|
||||||
@ -237,7 +237,7 @@ type CreatePollRequest struct {
|
|||||||
Recipient string `json:"recipient" example:"<phone number> OR <username> OR <group id>"`
|
Recipient string `json:"recipient" example:"<phone number> OR <username> OR <group id>"`
|
||||||
Question string `json:"question" example:"What's your favourite fruit?"`
|
Question string `json:"question" example:"What's your favourite fruit?"`
|
||||||
Answers []string `json:"answers" example:"apple,banana,orange"`
|
Answers []string `json:"answers" example:"apple,banana,orange"`
|
||||||
AllowMultipleSelections *bool `json:"allow_multiple_selections" example:"true"`
|
AllowMultipleSelections *bool `json:"allow_multiple_selections,omitempty" example:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreatePollResponse struct {
|
type CreatePollResponse struct {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest init
|
|||||||
Or, if you have `swag` installed:
|
Or, if you have `swag` installed:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swag init
|
swag init --requiredByDefault
|
||||||
```
|
```
|
||||||
|
|
||||||
Then run the app in `/src`
|
Then run the app in `/src`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user