Skip to content

Commit

Permalink
Support swagger (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 authored Oct 8, 2023
1 parent e7f1cdd commit 957dbd5
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 42 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
check_install:
which swagger || go get -u github.com/go-swagger/go-swagger/cmd/swagger

swagger: check_install
swagger generate spec -o ./docs/swagger.yaml --scan-models

install:
go mod tidy

run: install
go run main.go

.PHONY: check_install swagger install run
117 changes: 117 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
definitions:
Connection:
properties:
episode:
format: int64
type: integer
x-go-name: Episode
episode_name:
type: string
x-go-name: EpisodeName
links:
items:
$ref: '#/definitions/Link'
type: array
x-go-name: Links
nodes:
items:
$ref: '#/definitions/Node'
type: array
x-go-name: Nodes
type: object
x-go-package: github.com/anGie44/theOffice-api/models
Link:
properties:
source:
type: string
x-go-name: Source
target:
type: string
x-go-name: Target
value:
format: int64
type: integer
x-go-name: Value
type: object
x-go-package: github.com/anGie44/theOffice-api/models
Node:
properties:
id:
type: string
x-go-name: Id
type: object
x-go-package: github.com/anGie44/theOffice-api/models
Quote:
description: Quote defines the structure for an API quote
properties:
character:
description: the character the quote is associated with
type: string
x-go-name: Character
episode:
description: the episode the quote is from
format: int64
type: integer
x-go-name: Episode
episode_name:
description: the episode name the quote is from
type: string
x-go-name: EpisodeName
quote:
description: the quote
type: string
x-go-name: Quote
scene:
description: the scene the quote is from
format: int64
type: integer
x-go-name: Scene
season:
description: the season the quote is from
format: int64
type: integer
x-go-name: Season
type: object
x-go-package: github.com/anGie44/theOffice-api/models
paths:
/quotes:
get:
description: Return a list of quotes from the database
operationId: getQuotes
responses:
"200":
$ref: '#/responses/quotesResponse'
tags:
- quotes
/season/{season}/episode/{episode}:
get:
description: Return a list of quotes from the database for a given season and episode
operationId: getQuotesBySeasonAndEpisode
responses:
"200":
$ref: '#/responses/quotesResponse'
tags:
- quotes
/season/{season}/format/{format}:
get:
description: Return a list of quotes from the database for a given season and format
operationId: getQuotesBySeasonWithFormat
responses:
"200":
$ref: '#/responses/formattedQuotesResponse'
tags:
- interface
responses:
formattedQuotesResponse:
description: A list of quotes or connections
headers:
Body: {}
schema: {}
quotesResponse:
description: A list of quotes
headers:
Body:
items:
$ref: '#/definitions/Quote'
type: array
swagger: "2.0"
31 changes: 26 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,43 @@ go 1.20

require (
github.com/caarlos0/env/v9 v9.0.0
github.com/go-openapi/runtime v0.26.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/mxschmitt/golang-combinations v1.2.0
go.mongodb.org/mongo-driver v1.12.1
)

require (
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 957dbd5

Please sign in to comment.