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: unwrap import parameter #184

Merged
merged 1 commit into from
Oct 11, 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
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