Skip to content

Commit

Permalink
finish workspace api spec update
Browse files Browse the repository at this point in the history
  • Loading branch information
omerdemirok committed Nov 11, 2023
1 parent c861a50 commit 7239728
Show file tree
Hide file tree
Showing 264 changed files with 38 additions and 10,725 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ help: ## Display help
generate-core-code:
go run xata/internal/core_code_gen.go -scope=core

.PHONY: generate-core-workspace
generate-core-workspace:
.PHONY: generate-workspace-code
generate-workspace-code:
go run xata/internal/core_code_gen.go -scope=workspace
36 changes: 36 additions & 0 deletions xata/internal/core_code_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func updateWorkspaceAPISpecs(filePath string) error {
delete(openAPI.Paths, "/db/{db_branch_name}/migrations")
delete(openAPI.Paths, "/db/{db_branch_name}/migrations/execute")
delete(openAPI.Paths, "/db/{db_branch_name}/migrations/plan")

log.Println("updating file[] as fileArray")
columnEnums := openAPI.Components["schemas"].(map[string]any)["Column"].(map[string]any)["properties"].(map[string]any)["type"].(map[string]any)["enum"].([]any)
var newColumnEnums []string
for _, e := range columnEnums {
Expand All @@ -224,6 +226,40 @@ func updateWorkspaceAPISpecs(filePath string) error {

openAPI.Components["schemas"].(map[string]any)["Column"].(map[string]any)["properties"].(map[string]any)["type"].(map[string]any)["enum"] = newColumnEnums

for k, v := range openAPI.Components["schemas"].(map[string]any)["Column"].(map[string]any)["properties"].(map[string]any) {
if k == "file[]" {
openAPI.Components["schemas"].(map[string]any)["Column"].(map[string]any)["properties"].(map[string]any)["fileArray"] = v
delete(openAPI.Components["schemas"].(map[string]any)["Column"].(map[string]any)["properties"].(map[string]any), "file[]")
}

}

// TODO: Add issue link => https://github.com/omerdemirok/xata-go/issues/17
log.Println("removing reference of ProjectionConfig from QueryColumnsProjection")
var newOneOf []any
for _, o := range openAPI.Components["schemas"].(map[string]any)["QueryColumnsProjection"].(map[string]any)["items"].(map[string]any)["oneOf"].([]any) {
if o.(map[string]any)["$ref"] != nil && o.(map[string]any)["$ref"] == "#/components/schemas/ProjectionConfig" {
continue
}

newOneOf = append(newOneOf, o)
}
openAPI.Components["schemas"].(map[string]any)["QueryColumnsProjection"].(map[string]any)["items"].(map[string]any)["oneOf"] = newOneOf

log.Println("remove object value")
delete(openAPI.Components["schemas"].(map[string]any), "ObjectValue")

log.Println("removing reference for object value")
var newAnyOf []any
for _, o := range openAPI.Components["schemas"].(map[string]any)["DataInputRecord"].(map[string]any)["additionalProperties"].(map[string]any)["anyOf"].([]any) {
if o.(map[string]any)["$ref"] != nil && o.(map[string]any)["$ref"] == "#/components/schemas/ObjectValue" {
continue
}

newAnyOf = append(newAnyOf, o)
}
openAPI.Components["schemas"].(map[string]any)["DataInputRecord"].(map[string]any)["additionalProperties"].(map[string]any)["anyOf"] = newAnyOf

updatedOpenAPIData, err := json.Marshal(&openAPI)
if err != nil {
fmt.Println("Error marshaling updated OpenAPI data:", err)
Expand Down
11 changes: 0 additions & 11 deletions xata/internal/fern-workspace/fern/api/generators.yml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

180 changes: 0 additions & 180 deletions xata/internal/fern-workspace/generated/go/agg_expression.go

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7239728

Please sign in to comment.