Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): accept all geo types when creating geometryObject field from integration api by default #1247

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 50 additions & 9 deletions server/e2e/integration_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {
Expect().
Status(http.StatusBadRequest)

obj1 := e.POST(endpoint, sid1).
// region bool
res := e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "fKey1",
Expand All @@ -160,27 +161,67 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {
"required": false,
}).
Expect().
Status(http.StatusOK)
Status(http.StatusOK).
JSON().
Object()

obj1.JSON().Object().ContainsKey("id")
res.ContainsKey("id")

obj := e.GET("/api/models/{modelId}", mId1).
res = e.GET("/api/models/{modelId}", mId1).
WithHeader("authorization", "Bearer "+secret).
Expect().
Status(http.StatusOK).
JSON().
Object().
HasValue("id", mId1.String()).
Object()

res.HasValue("id", mId1.String()).
HasValue("name", "m1").
HasValue("description", "m1 desc").
HasValue("public", true).
HasValue("key", ikey1.String()).
HasValue("projectId", pid).
HasValue("schemaId", sid1)

obj.Value("createdAt").NotNull()
obj.Value("updatedAt").NotNull()
obj.Value("lastModified").NotNull()
res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
// endregion

// region GeoObject
res = e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "fKey2",
"type": "geometryObject",
"multiple": false,
"required": false,
}).
Expect().
Status(http.StatusOK).
JSON().
Object()

res.ContainsKey("id")

res = e.GET("/api/models/{modelId}", mId1).
WithHeader("authorization", "Bearer "+secret).
Expect().
Status(http.StatusOK).
JSON().
Object()

res.HasValue("id", mId1.String()).
HasValue("name", "m1").
HasValue("description", "m1 desc").
HasValue("public", true).
HasValue("key", ikey1.String()).
HasValue("projectId", pid).
HasValue("schemaId", sid1)

res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
// endregion
}

// PATCH /api/models/{modelId}/fields/{FieldIdOrKey}
Expand Down
2 changes: 1 addition & 1 deletion server/internal/adapter/integration/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func FromSchemaTypeProperty(t integrationapi.ValueType, multiple bool) (tpRes *s
case integrationapi.ValueTypeUrl:
tpRes = schema.NewURL().TypeProperty()
case integrationapi.ValueTypeGeometryObject:
tpRes = schema.NewGeometryObject(nil).TypeProperty()
tpRes = schema.NewGeometryObject(schema.GeometryAllSupportedTypes()).TypeProperty()
case integrationapi.ValueTypeGeometryEditor:
tpRes = schema.NewGeometryEditor(nil).TypeProperty()
default:
Expand Down
12 changes: 12 additions & 0 deletions server/pkg/schema/field_geometry_object_supported_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ func GeometryObjectSupportedTypeFrom(s string) GeometryObjectSupportedType {
return GeometryObjectSupportedType("")
}
}

func GeometryAllSupportedTypes() GeometryObjectSupportedTypeList {
return GeometryObjectSupportedTypeList{
GeometryObjectSupportedTypePoint,
GeometryObjectSupportedTypeMultiPoint,
GeometryObjectSupportedTypeLineString,
GeometryObjectSupportedTypeMultiLineString,
GeometryObjectSupportedTypePolygon,
GeometryObjectSupportedTypeMultiPolygon,
GeometryObjectSupportedTypeGeometryCollection,
}
}
Loading