-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement Graph Sectionalize API (#87)
- Loading branch information
1 parent
5f033b3
commit d1b6fca
Showing
61 changed files
with
2,977 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
post: | ||
tags: | ||
- Graphs | ||
operationId: graphs-sectionalize | ||
summary: Sectionalize into graphs | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../schemas/interface/graphs/sectionalize/GraphSectionalizeRequest.yaml | ||
responses: | ||
"200": | ||
description: OK - Returns graphs from sections | ||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../schemas/interface/graphs/sectionalize/GraphSectionalizeResponse.yaml | ||
"400": | ||
description: Bad Request - Invalid request | ||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../schemas/interface/graphs/sectionalize/GraphSectionalizeErrorResponse.yaml | ||
"404": | ||
description: Not Found - Graph not found or not authorized | ||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../schemas/interface/graphs/sectionalize/GraphSectionalizeErrorResponse.yaml | ||
"500": | ||
description: Internal Server Error - Server error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../schemas/interface/app/ApplicationErrorResponse.yaml |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
type: object | ||
description: Graph object | ||
properties: | ||
id: | ||
type: string | ||
description: Auto-generated section ID | ||
example: 123e4567-e89b-12d3-a456-426614174000 | ||
name: | ||
type: string | ||
maxLength: 100 | ||
description: Graph name | ||
example: Overview | ||
paragraph: | ||
type: string | ||
maxLength: 40000 | ||
description: Graph paragraph | ||
example: | | ||
## Introduction | ||
This is the introduction of the paper. | ||
required: | ||
- id | ||
- name | ||
- paragraph |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...enapi/schemas/entity/section/Section.yaml → ...emas/entity/section/SectionOfChapter.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
docs/openapi/schemas/entity/section/SectionWithoutAutofieldListError.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type: object | ||
description: Error Message for SectionWithoutAutofield list | ||
properties: | ||
message: | ||
type: string | ||
description: Error message for overall of sections | ||
example: sections is required, but got empty list | ||
items: | ||
type: array | ||
items: | ||
$ref: ./SectionWithoutAutofieldError.yaml |
15 changes: 15 additions & 0 deletions
15
docs/openapi/schemas/interface/graphs/sectionalize/GraphSectionalizeErrorResponse.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type: object | ||
description: Error Response Body for Graph Sectionalize API | ||
properties: | ||
message: | ||
type: string | ||
description: Error message when request body format is invalid | ||
example: unexpected EOF | ||
user: | ||
$ref: ../../../entity/user/UserOnlyIdError.yaml | ||
project: | ||
$ref: ../../../entity/project/ProjectOnlyIdError.yaml | ||
chapter: | ||
$ref: ../../../entity/chapter/ChapterOnlyIdError.yaml | ||
sections: | ||
$ref: ../../../entity/section/SectionWithoutAutofieldListError.yaml |
9 changes: 5 additions & 4 deletions
9
...ectionalize/PaperSectionalizeRequest.yaml → ...ectionalize/GraphSectionalizeRequest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
type: object | ||
description: Request Body for Paper Sectionalize API | ||
description: Request Body for Graph Sectionalize API | ||
properties: | ||
user: | ||
$ref: ../../../entity/user/UserOnlyId.yaml | ||
project: | ||
$ref: ../../../entity/project/ProjectOnlyId.yaml | ||
paper: | ||
$ref: ../../../entity/paper/PaperOnlyId.yaml | ||
chapter: | ||
$ref: ../../../entity/chapter/ChapterOnlyId.yaml | ||
sections: | ||
type: array | ||
items: | ||
$ref: ../../../entity/section/SectionWithoutAutofield.yaml | ||
maxItems: 20 | ||
required: | ||
- user | ||
- project | ||
- paper | ||
- chapter | ||
- sections |
10 changes: 10 additions & 0 deletions
10
docs/openapi/schemas/interface/graphs/sectionalize/GraphSectionalizeResponse.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
type: object | ||
description: Response Body for Graph Sectionalize API | ||
properties: | ||
graphs: | ||
type: array | ||
items: | ||
$ref: ../../../entity/graph/Graph.yaml | ||
maxItems: 20 | ||
required: | ||
- graphs |
13 changes: 0 additions & 13 deletions
13
docs/openapi/schemas/interface/papers/sectionalize/PaperSectionalizeErrorResponse.yaml
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
docs/openapi/schemas/interface/papers/sectionalize/PaperSectionalizeResponse.yaml
This file was deleted.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
fixtures/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata
Binary file not shown.
Binary file modified
BIN
+4.21 KB
(150%)
fixtures/firestore_export/all_namespaces/all_kinds/output-0
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
fixtures/firestore_export/firestore_export.overall_export_metadata
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/kumachan-mis/knodeledge-api/internal/model" | ||
"github.com/kumachan-mis/knodeledge-api/internal/usecase" | ||
) | ||
|
||
type GraphApi interface { | ||
HandleSectionalize(c *gin.Context) | ||
} | ||
|
||
type graphApi struct { | ||
usecase usecase.GraphUseCase | ||
} | ||
|
||
func NewGraphApi(usecase usecase.GraphUseCase) GraphApi { | ||
return graphApi{usecase: usecase} | ||
} | ||
|
||
func (api graphApi) HandleSectionalize(c *gin.Context) { | ||
var request model.GraphSectionalizeRequest | ||
if err := c.ShouldBindJSON(&request); err != nil { | ||
c.JSON(http.StatusBadRequest, model.GraphSectionalizeErrorResponse{ | ||
Message: JsonBindErrorToMessage(err), | ||
}) | ||
return | ||
} | ||
|
||
res, ucErr := api.usecase.SectionalizeGraph(request) | ||
|
||
if ucErr != nil && ucErr.Code() == usecase.DomainValidationError { | ||
resErr := UseCaseErrorToResponse(ucErr) | ||
c.JSON(http.StatusBadRequest, model.GraphSectionalizeErrorResponse{ | ||
Message: UseCaseErrorToMessage(ucErr), | ||
User: resErr.User, | ||
Project: resErr.Project, | ||
Chapter: resErr.Chapter, | ||
Sections: resErr.Sections, | ||
}) | ||
return | ||
} | ||
|
||
if ucErr != nil && ucErr.Code() == usecase.InvalidArgumentError { | ||
c.JSON(http.StatusBadRequest, model.GraphSectionalizeErrorResponse{ | ||
Message: UseCaseErrorToMessage(ucErr), | ||
}) | ||
return | ||
} | ||
|
||
if ucErr != nil && ucErr.Code() == usecase.NotFoundError { | ||
c.JSON(http.StatusNotFound, model.GraphSectionalizeErrorResponse{ | ||
Message: UseCaseErrorToMessage(ucErr), | ||
}) | ||
return | ||
} | ||
|
||
if ucErr != nil { | ||
c.JSON(http.StatusInternalServerError, model.ApplicationErrorResponse{ | ||
Message: UseCaseErrorToMessage(ucErr), | ||
}) | ||
return | ||
} | ||
|
||
c.JSON(http.StatusCreated, res) | ||
} |
Oops, something went wrong.