style(spike): fix lint issues introduced by Huma spike
License headers on new files, gofmt on routes.go import ordering, unused imports in test files, testifylint assert.Contains/InDelta, and infertypeargs cleanups.
This commit is contained in:
parent
4b1202df17
commit
0b08131dad
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// Package humaecho5 is a Huma adapter for labstack/echo/v5.
|
||||
//
|
||||
// Adapted from github.com/danielgtaylor/huma/v2/adapters/humaecho (MIT)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,25 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package humaecho5_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.vikunja.io/api/pkg/modules/humaecho5"
|
||||
|
|
@ -66,6 +81,6 @@ func TestOpenAPISpecServed(t *testing.T) {
|
|||
rec := httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
require.Equal(t, 200, rec.Code)
|
||||
assert.True(t, strings.Contains(rec.Body.String(), `"openapi":"3.1`),
|
||||
assert.Contains(t, rec.Body.String(), `"openapi":"3.1`,
|
||||
"expected OAS 3.1 header, got %s", rec.Body.String())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package humaapi
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package humaapi
|
||||
|
||||
import (
|
||||
|
|
@ -49,7 +65,7 @@ func TestRegisterEmitsFiveOperations(t *testing.T) {
|
|||
e := echo.New()
|
||||
api := humaecho5.New(e, huma.DefaultConfig("spike", "0.0.1"))
|
||||
|
||||
Register[*fakeObj](api, Config[*fakeObj, SingleID]{
|
||||
Register(api, Config[*fakeObj, SingleID]{
|
||||
Tag: "fakes",
|
||||
BasePath: "/fakes",
|
||||
ItemPath: "/fakes/{id}",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package humaapi
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package humaapi
|
||||
|
||||
import (
|
||||
|
|
@ -5,7 +21,6 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/danielgtaylor/huma/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
|
@ -26,6 +41,6 @@ func TestVikunjaErrorShape_BasicCodeMessage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestVikunjaErrorShape_StatusCoderInterface(t *testing.T) {
|
||||
var e huma.StatusError = NewVikunjaError(http.StatusNotFound, "not found")
|
||||
e := NewVikunjaError(http.StatusNotFound, "not found")
|
||||
assert.Equal(t, http.StatusNotFound, e.GetStatus())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package humaapi
|
||||
|
||||
import (
|
||||
|
|
@ -10,7 +26,7 @@ import (
|
|||
// given Huma API. Runs alongside (not replacing) the legacy swag-driven
|
||||
// routes for the duration of the spike.
|
||||
func RegisterLabelRoutes(api huma.API) {
|
||||
Register[*models.Label](api, Config[*models.Label, SingleID]{
|
||||
Register(api, Config[*models.Label, SingleID]{
|
||||
Tag: "labels",
|
||||
BasePath: "/labels",
|
||||
ItemPath: "/labels/{id}",
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ import (
|
|||
backgroundHandler "code.vikunja.io/api/pkg/modules/background/handler"
|
||||
"code.vikunja.io/api/pkg/modules/background/unsplash"
|
||||
"code.vikunja.io/api/pkg/modules/background/upload"
|
||||
"code.vikunja.io/api/pkg/modules/humaecho5"
|
||||
"code.vikunja.io/api/pkg/modules/migration"
|
||||
csvmigrator "code.vikunja.io/api/pkg/modules/migration/csv"
|
||||
migrationHandler "code.vikunja.io/api/pkg/modules/migration/handler"
|
||||
|
|
@ -78,7 +79,6 @@ import (
|
|||
vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file"
|
||||
"code.vikunja.io/api/pkg/modules/migration/wekan"
|
||||
"code.vikunja.io/api/pkg/plugins"
|
||||
"code.vikunja.io/api/pkg/modules/humaecho5"
|
||||
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
|
||||
"code.vikunja.io/api/pkg/routes/api/v1/humaapi"
|
||||
"code.vikunja.io/api/pkg/routes/caldav"
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func TestHumaLabel_Create_ReadOne_via_OAS31Route(t *testing.T) {
|
|||
var fetched map[string]any
|
||||
require.NoError(t, json.Unmarshal(readRec.Body.Bytes(), &fetched))
|
||||
assert.Equal(t, "spike", fetched["title"])
|
||||
assert.Equal(t, idFloat, fetched["id"])
|
||||
assert.InDelta(t, idFloat, fetched["id"], 0)
|
||||
}
|
||||
|
||||
// TestHumaLabel_OpenAPISpecContainsLabelPaths proves the spec is served
|
||||
|
|
|
|||
Loading…
Reference in New Issue