Skip to content

Commit

Permalink
Add example and description
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Sung <[email protected]>
  • Loading branch information
baegjae committed Aug 31, 2021
1 parent d012b00 commit 6a0b246
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 21 deletions.
28 changes: 21 additions & 7 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,30 +154,44 @@ var doc = `{
],
"properties": {
"author": {
"type": "string"
"description": "book author",
"type": "string",
"example": "David Wiesner"
},
"publisher": {
"type": "string"
"description": "book publisher",
"type": "string",
"example": "Clarion Books"
},
"title": {
"type": "string"
"description": "book title",
"type": "string",
"example": "The Three Pigs"
}
}
},
"model.BookResponseDTO": {
"type": "object",
"properties": {
"author": {
"type": "string"
"description": "book author",
"type": "string",
"example": "David Wiesner"
},
"id": {
"type": "integer"
"description": "book id",
"type": "integer",
"example": 1234
},
"publisher": {
"type": "string"
"description": "book publisher",
"type": "string",
"example": "Clarion Books"
},
"title": {
"type": "string"
"description": "book title",
"type": "string",
"example": "The Three Pigs"
}
}
}
Expand Down
28 changes: 21 additions & 7 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,44 @@
],
"properties": {
"author": {
"type": "string"
"description": "book author",
"type": "string",
"example": "David Wiesner"
},
"publisher": {
"type": "string"
"description": "book publisher",
"type": "string",
"example": "Clarion Books"
},
"title": {
"type": "string"
"description": "book title",
"type": "string",
"example": "The Three Pigs"
}
}
},
"model.BookResponseDTO": {
"type": "object",
"properties": {
"author": {
"type": "string"
"description": "book author",
"type": "string",
"example": "David Wiesner"
},
"id": {
"type": "integer"
"description": "book id",
"type": "integer",
"example": 1234
},
"publisher": {
"type": "string"
"description": "book publisher",
"type": "string",
"example": "Clarion Books"
},
"title": {
"type": "string"
"description": "book title",
"type": "string",
"example": "The Three Pigs"
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ definitions:
model.BookRequestDTO:
properties:
author:
description: book author
example: David Wiesner
type: string
publisher:
description: book publisher
example: Clarion Books
type: string
title:
description: book title
example: The Three Pigs
type: string
required:
- author
Expand All @@ -15,12 +21,20 @@ definitions:
model.BookResponseDTO:
properties:
author:
description: book author
example: David Wiesner
type: string
id:
description: book id
example: 1234
type: integer
publisher:
description: book publisher
example: Clarion Books
type: string
title:
description: book title
example: The Three Pigs
type: string
type: object
info:
Expand Down
14 changes: 7 additions & 7 deletions model/book_dto.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package model

type BookRequestDTO struct {
Title string `json:"title" binding:"required,min=5""`
Author string `json:"author" binding:"required,min=5""`
Publisher string `json:"publisher" binding:"required,min=5""`
Title string `json:"title" binding:"required,min=5" example:"The Three Pigs"` // book title
Author string `json:"author" binding:"required,min=5" example:"David Wiesner"` // book author
Publisher string `json:"publisher" binding:"required,min=5" example:"Clarion Books"` // book publisher
}

type BookResponseDTO struct {
ID uint `json:"id"`
Title string `json:"title"`
Author string `json:"author"`
Publisher string `json:"publisher"`
ID uint `json:"id" example:"1234"` // book id
Title string `json:"title" example:"The Three Pigs"` // book title
Author string `json:"author" example:"David Wiesner"` // book author
Publisher string `json:"publisher" example:"Clarion Books"` // book publisher
}

0 comments on commit 6a0b246

Please sign in to comment.