Skip to content

Commit

Permalink
Merge pull request #184 from phiHero/patch
Browse files Browse the repository at this point in the history
fix: unwrap import parameter
  • Loading branch information
kishorenc authored Oct 11, 2024
2 parents f3e98fa + 633f8c8 commit b748897
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions typesense/api/client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions typesense/api/generator/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2242,14 +2242,14 @@ paths:
name: action
schema:
$ref: '#/components/schemas/IndexAction'
- in: query
name: dirty_values
schema:
$ref: '#/components/schemas/DirtyValues'
- in: query
name: batch_size
schema:
type: integer
- in: query
name: dirty_values
schema:
$ref: '#/components/schemas/DirtyValues'
- in: query
name: remote_embedding_batch_size
schema:
Expand Down
11 changes: 10 additions & 1 deletion typesense/api/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,16 @@ func unwrapImportDocuments(m *yml) {
newMap["name"] = obj.Key
newMap["in"] = query
newMap["schema"] = make(yml)
newMap["schema"].(yml)["type"] = obj.Value.(yml)["type"].(string)
switch {
// if the param is referencing a schema
case obj.Value.(yml)["type"] == nil:
newMap["schema"].(yml)["$ref"] = obj.Value.(yml)["$ref"].(string)
case obj.Value.(yml)["type"].(string) == array:
newMap["schema"].(yml)["type"] = array
newMap["schema"].(yml)["items"] = obj.Value.(yml)["items"]
default:
newMap["schema"].(yml)["type"] = obj.Value.(yml)["type"].(string)
}
if obj.Value.(yml)["enum"] != nil {
newMap["schema"].(yml)["enum"] = obj.Value.(yml)["enum"]
}
Expand Down
12 changes: 4 additions & 8 deletions typesense/api/generator/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,10 @@ paths:
type: integer
return_doc:
type: boolean
- name: action
in: query
schema:
$ref: "#/components/schemas/IndexAction"
- name: dirty_values
in: query
schema:
$ref: "#/components/schemas/DirtyValues"
action:
$ref: "#/components/schemas/IndexAction"
dirty_values:
$ref: "#/components/schemas/DirtyValues"
requestBody:
description: The json array of documents or the JSONL file to import
content:
Expand Down
2 changes: 1 addition & 1 deletion typesense/api/types_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typesense/test/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestDocumentsImport(t *testing.T) {
newDocument("127", withCompanyName("Company3")),
}

params := &api.ImportDocumentsParams{Action: pointer.Any(api.Create)}
params := &api.ImportDocumentsParams{Action: pointer.Any(api.Create), DirtyValues: pointer.Any(api.CoerceOrDrop)}
responses, err := typesenseClient.Collection(collectionName).Documents().Import(context.Background(), documents, params)

require.NoError(t, err)
Expand Down

0 comments on commit b748897

Please sign in to comment.