Skip to content

Commit

Permalink
chore: update swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
luigibarbato committed Oct 9, 2023
1 parent 17eb32c commit aa59072
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 91 deletions.
71 changes: 31 additions & 40 deletions api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 45 additions & 43 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
openapi: 3.0.2
x-stoplight:
id: zo1541bc64oxo
id: 44w9u0405b53e
info:
title: Unconditional
version: '1.0'
version: "1.0"
servers:
- url: 'https://api.unconditional.day/v1'
- url: 'http://localhost:8080'
- url: '127.0.0.1:8080'
- url: "https://api.unconditional.day/v1"
- url: "http://localhost:8080"
- url: "127.0.0.1:8080"
paths:
"/v1/search/feed/{query}":
get:
Expand All @@ -34,29 +34,8 @@ paths:
schema:
type: string
x-stoplight:
id: pacmz9rv7a1k1
/v1/version:
get:
summary: Your GET endpoint
tags: []
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
$ref: "#/components/schemas/ServerVersion"
operationId: get-v1-version
x-stoplight:
id: flrb4hew86v1s
requestBody:
content:
application/json:
schema:
type: object
properties: {}
/v1/informer/wiki/{query}:
id: wosl2fd4xhhrd
"/v1/search/context/{query}":
get:
responses:
"200":
Expand All @@ -65,7 +44,7 @@ paths:
application/json:
schema:
type: object
$ref: "#/components/schemas/WikiResult"
$ref: "#/components/schemas/SearchContextDetails"
"500":
description: Internal Server Error
content:
Expand All @@ -79,7 +58,29 @@ paths:
required: true
schema:
type: string

x-stoplight:
id: idoe8qr80ebxd
"/v1/version":
get:
summary: Your GET endpoint
tags: []
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
$ref: "#/components/schemas/ServerVersion"
operationId: get-v1-version
x-stoplight:
id: q4lvzczpgn9wh
requestBody:
content:
application/json:
schema:
type: object
properties: {}
components:
schemas:
FeedItem:
Expand Down Expand Up @@ -109,7 +110,7 @@ components:
- language
- date
x-stoplight:
id: r1huzg5l9oykp
id: xa4xmb6bpguaf
FeedImage:
type: object
properties:
Expand All @@ -121,10 +122,11 @@ components:
- url
- title
x-stoplight:
id: g5p7hclip2ydk

WikiResult:
id: cmmybtqamyqiy
SearchContextDetails:
type: object
x-stoplight:
id: 2bea7d1686f73
properties:
title:
type: string
Expand All @@ -136,13 +138,13 @@ components:
type: string
language:
type: string

required:
- title
- link
- summary
- thumbnail
- language
title: SearchContextDetails
Error:
type: object
properties:
Expand All @@ -154,11 +156,11 @@ components:
- message
- code
x-stoplight:
id: gdj84rexxmxft
id: ugjrjhvkdmen2
ServerVersion:
title: ServerVersion
x-stoplight:
id: z6s8y1u6qlv0p
id: 24qo1fm939bg5
type: object
properties:
source:
Expand All @@ -171,34 +173,34 @@ components:
SourceReleaseVersion:
title: SourceReleaseVersion
x-stoplight:
id: 9jgspbctklvnr
id: ufsclw4vu3qp5
type: object
properties:
version:
type: string
x-stoplight:
id: ebqolha5zfx9n
id: t6xp7ev3nprdj
lastUpdatedAt:
type: string
x-stoplight:
id: xj2nln4v17pzd
id: 26hfi8gtj9bdi
required:
- version
- lastUpdatedAt
ServerBuildVersion:
title: ServerBuildVersion
x-stoplight:
id: 7r5btva4x51y3
id: p7byzats6s3zt
type: object
properties:
commit:
type: string
x-stoplight:
id: kbcq283u8u0h0
id: eoik296b0ddt3
version:
type: string
x-stoplight:
id: sia3kpjqax11w
id: jup15zjavkg3a
required:
- commit
- version
1 change: 0 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/unconditionalday/server/internal/service"
"github.com/unconditionalday/server/internal/version"
cobrax "github.com/unconditionalday/server/internal/x/cobra"
"go.uber.org/zap"
)

var (
Expand Down
5 changes: 2 additions & 3 deletions internal/client/wikipedia/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const (
)

var (
ErrEmptyQuery = errors.New("query string must not be empty")
ErrEmptyLanguage = errors.New("language string must not be empty")
ErrEmptyQuery = errors.New("query string must not be empty")
ErrEmptyLanguage = errors.New("language string must not be empty")
ErrDisambiguationResult = errors.New("disambiguation result")
)

Expand Down Expand Up @@ -165,7 +165,6 @@ func (w *Client) FetchContextDetails(query string, lang string) (search.ContextD
Title: wikiPage.Title,
Language: wikiPage.Language,
Link: wikiPage.URL,
Source: "Wikipedia",
Summary: summary,
Thumbnail: thumbnail,
}, nil
Expand Down
3 changes: 1 addition & 2 deletions internal/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ type ContextDetails struct {
Summary string
Thumbnail string
Language string
Source string
}

func (i ContextDetails) IsValid() bool {
return i.Title != "" && i.Link != "" && i.Summary != "" && i.Thumbnail != "" && i.Language != "" && i.Source != ""
return i.Title != "" && i.Link != "" && i.Summary != "" && i.Thumbnail != "" && i.Language != ""
}

type SearchClient interface {
Expand Down
4 changes: 2 additions & 2 deletions internal/webserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (s *Server) GetV1Version(ctx echo.Context) error {
return ctx.JSON(http.StatusOK, v)
}

func (s *Server) GetV1InformerWikiQuery(ctx echo.Context, query string) error {
func (s *Server) GetV1SearchContextQuery(ctx echo.Context, query string) error {
// TODO: add language support
searchRes, err := s.search.FetchContextDetails(query, "en")
if err != nil {
Expand All @@ -129,7 +129,7 @@ func (s *Server) GetV1InformerWikiQuery(ctx echo.Context, query string) error {
return ctx.JSON(http.StatusInternalServerError, e)
}

res := api.WikiResult{
res := api.SearchContextDetails{
Language: searchRes.Language,
Link: searchRes.Link,
Summary: searchRes.Summary,
Expand Down

0 comments on commit aa59072

Please sign in to comment.