Skip to content

Commit f26aa71

Browse files
authored
fix: make service config optional in API design (#325)
Remove config from Required fields in the Goa DSL and add omitempty to the JSON tag. The custom validation layer already handles nil configs with sensible defaults, but the generated validation was rejecting requests before custom parsing could run. Normalize nil config to an empty map in the API conversion layer so downstream code never needs nil checks.
1 parent b6b6f3b commit f26aa71

14 files changed

Lines changed: 99 additions & 62 deletions

File tree

api/apiv1/design/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ var ServiceSpec = g.Type("ServiceSpec", func() {
199199
"llm_model": "gpt-4",
200200
"openai_api_key": "sk-...",
201201
})
202-
g.Meta("struct:tag:json", "config")
202+
g.Meta("struct:tag:json", "config,omitempty")
203203
})
204204
g.Attribute("cpus", g.String, func() {
205205
g.Description("The number of CPUs to allocate for this service. It can include the SI suffix 'm', e.g. '500m' for 500 millicpus. Defaults to container defaults if unspecified.")
@@ -225,7 +225,7 @@ var ServiceSpec = g.Type("ServiceSpec", func() {
225225
g.Meta("struct:tag:json", "database_connection,omitempty")
226226
})
227227

228-
g.Required("service_id", "service_type", "version", "host_ids", "config")
228+
g.Required("service_id", "service_type", "version", "host_ids")
229229
})
230230

231231
var BackupRepositorySpec = g.Type("BackupRepositorySpec", func() {

api/apiv1/gen/control_plane/service.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/client/encode_decode.go

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/client/types.go

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/server/encode_decode.go

Lines changed: 14 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/server/types.go

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi.yaml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi3.json

Lines changed: 7 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi3.yaml

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)