diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f86efbd..f4e032de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,10 +15,10 @@ jobs: name: Mod runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.22.2' - - uses: actions/checkout@v4 + go-version-file: 'go.mod' - uses: actions/cache@v3.3.2 with: path: ~/go/pkg/mod @@ -31,10 +31,10 @@ jobs: env: GOCACHE: "/tmp/go/cache" steps: + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.22.2' - - uses: actions/checkout@v4 + go-version-file: 'go.mod' - uses: actions/cache@v3.3.2 with: path: ~/go/pkg/mod @@ -66,10 +66,10 @@ jobs: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: anke-to steps: + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.22.2' - - uses: actions/checkout@v4 + go-version-file: 'go.mod' - uses: actions/cache@v3.3.2 with: path: ~/go/pkg/mod @@ -97,10 +97,10 @@ jobs: name: Lint runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.22.2' - - uses: actions/checkout@v4 + go-version-file: 'go.mod' - name: golangci-lint uses: reviewdog/action-golangci-lint@v2.3 with: diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index f0cb40ce..443cccb1 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -882,17 +882,20 @@ components: ResponsesWithQuestionnaireInfo: type: array items: - allOf: - - $ref: "#/components/schemas/Response" - - type: object - properties: - questionnaire_info: - allOf: - - $ref: "#/components/schemas/QuestionnaireTitle" - - $ref: "#/components/schemas/QuestionnaireResponseDueDateTime" - - $ref: "#/components/schemas/QuestionnaireCreatedAt" - - $ref: "#/components/schemas/QuestionnaireModifiedAt" - - $ref: "#/components/schemas/QuestionnaireIsTargetingMe" + $ref: "#/components/schemas/ResponseWithQuestionnaireInfoItem" + ResponseWithQuestionnaireInfoItem: + type: object + allOf: + - $ref: "#/components/schemas/Response" + - type: object + properties: + questionnaire_info: + allOf: + - $ref: "#/components/schemas/QuestionnaireTitle" + - $ref: "#/components/schemas/QuestionnaireResponseDueDateTime" + - $ref: "#/components/schemas/QuestionnaireCreatedAt" + - $ref: "#/components/schemas/QuestionnaireModifiedAt" + - $ref: "#/components/schemas/QuestionnaireIsTargetingMe" ResponseBody: oneOf: - $ref: "#/components/schemas/ResponseBodyText" @@ -960,27 +963,30 @@ components: Result: type: array items: - allOf: - - $ref: "#/components/schemas/QuestionnaireID" - - type: object - properties: - response_id: - type: integer - example: 1 - submitted_at: - type: string - format: date-time - example: 2020-01-01T00:00:00+09:00 - modified_at: - type: string - format: date-time - example: 2020-01-01T00:00:00+09:00 - required: - - response_id - - respondent - - submitted_at - - modified_at - - $ref: "#/components/schemas/NewResponse" + $ref: "#/components/schemas/ResultItem" + ResultItem: + type: object + allOf: + - $ref: "#/components/schemas/QuestionnaireID" + - type: object + properties: + response_id: + type: integer + example: 1 + submitted_at: + type: string + format: date-time + example: 2020-01-01T00:00:00+09:00 + modified_at: + type: string + format: date-time + example: 2020-01-01T00:00:00+09:00 + required: + - response_id + - respondent + - submitted_at + - modified_at + - $ref: "#/components/schemas/NewResponse" UsersAndGroups: type: object properties: diff --git a/router/responses.go b/router/responses.go index 81d11d64..fde97cfd 100644 --- a/router/responses.go +++ b/router/responses.go @@ -323,9 +323,9 @@ func (r *Response) EditResponse(c echo.Context) error { c.Logger().Errorf("failed to get scale labels: %+v", err) return echo.NewHTTPError(http.StatusInternalServerError, err) } - scaleLabelMap := make(map[int]*model.ScaleLabels, len(scaleLabels)) + scaleLabelMap := make(map[int]model.ScaleLabels, len(scaleLabels)) for _, label := range scaleLabels { - scaleLabelMap[label.QuestionID] = &label + scaleLabelMap[label.QuestionID] = label } // LinearScaleのパターンマッチ @@ -334,9 +334,9 @@ func (r *Response) EditResponse(c echo.Context) error { case "LinearScale": label, ok := scaleLabelMap[body.QuestionID] if !ok { - label = &model.ScaleLabels{} + label = model.ScaleLabels{} } - if err := r.CheckScaleLabel(*label, body.Body.ValueOrZero()); err != nil { + if err := r.CheckScaleLabel(label, body.Body.ValueOrZero()); err != nil { c.Logger().Infof("invalid scale label: %+v", err) return echo.NewHTTPError(http.StatusBadRequest, err) }