diff --git a/clients/algoliasearch-client-go/algolia/utils/utils.go b/clients/algoliasearch-client-go/algolia/utils/utils.go index a7fd0a4338..317a2eb975 100644 --- a/clients/algoliasearch-client-go/algolia/utils/utils.go +++ b/clients/algoliasearch-client-go/algolia/utils/utils.go @@ -26,7 +26,7 @@ func (v Nullable[T]) Get() *T { func (v *Nullable[T]) Set(val *T) { v.value = val - v.isSet = true + v.isSet = val != nil } func (v Nullable[T]) IsSet() bool { @@ -39,7 +39,7 @@ func (v *Nullable[T]) Unset() { } func NewNullable[T any](val *T) *Nullable[T] { - return &Nullable[T]{value: val, isSet: true} + return &Nullable[T]{value: val, isSet: val != nil} } func (v Nullable[T]) MarshalJSON() ([]byte, error) { @@ -47,8 +47,10 @@ func (v Nullable[T]) MarshalJSON() ([]byte, error) { } func (v *Nullable[T]) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) + err := json.Unmarshal(src, &v.value) + v.isSet = v.value != nil + + return err } // IsNilOrEmpty checks if an input is nil or empty. diff --git a/scripts/install.sh b/scripts/install.sh index 521af27296..c4063dabba 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -19,7 +19,7 @@ apic() { export apic _list_languages() { - cat $ROOT/config/clients.config.json | jq -r 'keys[]' + cat $ROOT/config/clients.config.json | jq -r 'keys[] | select(. != "$schema")' } _list_languages_all() { diff --git a/specs/ingestion/common/schemas/event.yml b/specs/ingestion/common/schemas/event.yml index e7f69350ef..c8083ad51b 100644 --- a/specs/ingestion/common/schemas/event.yml +++ b/specs/ingestion/common/schemas/event.yml @@ -18,8 +18,10 @@ Event: minimum: 0 multipleOf: 1 data: - type: object - additionalProperties: true + oneOf: + - type: object + additionalProperties: true + - type: 'null' publishedAt: $ref: './common.yml#/publishedAt' required: @@ -31,8 +33,10 @@ Event: - publishedAt EventStatus: - type: string - enum: [created, started, retried, failed, succeeded, critical] + oneOf: + - type: string + enum: [created, started, retried, failed, succeeded, critical] + - type: 'null' EventType: type: string diff --git a/specs/ingestion/common/schemas/source.yml b/specs/ingestion/common/schemas/source.yml index 92c142bc85..d72fa7778c 100644 --- a/specs/ingestion/common/schemas/source.yml +++ b/specs/ingestion/common/schemas/source.yml @@ -352,7 +352,7 @@ SourceDocker: properties: image: type: string - description: Shortname of the image, as returned by the referential. + description: Name of the connector. example: zendesk configuration: type: object diff --git a/templates/go/model_simple.mustache b/templates/go/model_simple.mustache index 7b9593233a..8c28c2c0aa 100644 --- a/templates/go/model_simple.mustache +++ b/templates/go/model_simple.mustache @@ -274,16 +274,26 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) { } {{/vendorExtensions.x-golang-is-container}} {{^vendorExtensions.x-golang-is-container}} - if {{#required}}true{{/required}}{{^required}}o.{{name}}.IsSet(){{/required}} { + {{#required}} + toSerialize["{{baseName}}"] = o.{{name}}.Get() + {{/required}} + {{^required}} + if o.{{name}}.IsSet() { toSerialize["{{baseName}}"] = o.{{name}}.Get() } + {{/required}} {{/vendorExtensions.x-golang-is-container}} {{/isNullable}} {{! if argument is not nullable, don't set it if it is nil}} {{^isNullable}} - if {{#required}}true{{/required}}{{^required}}o.{{name}} != nil{{/required}} { + {{#required}} + toSerialize["{{baseName}}"] = o.{{name}} + {{/required}} + {{^required}} + if o.{{name}} != nil { toSerialize["{{baseName}}"] = o.{{name}} } + {{/required}} {{/isNullable}} {{/vars}} {{#isAdditionalPropertiesTrue}} @@ -443,4 +453,4 @@ func (o {{classname}}) String() string { } {{/isAdditionalPropertiesTrue}} return fmt.Sprintf("{{classname}} {\n%s}", out) -} \ No newline at end of file +} diff --git a/templates/python/model_generic.mustache b/templates/python/model_generic.mustache index 605ef476be..25defe31eb 100644 --- a/templates/python/model_generic.mustache +++ b/templates/python/model_generic.mustache @@ -12,7 +12,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{> model_description}} {{#vars}} - {{name}}: {{^required}}Optional[{{/required}}{{{dataType}}}{{^required}}]{{/required}}{{^required}} = None{{/required}} + {{name}}: {{^required}}Optional[{{/required}}{{#required}}{{#isNullable}}Union[{{/isNullable}}{{/required}}{{{dataType}}}{{#required}}{{#isNullable}}, None]{{/isNullable}}{{/required}}{{^required}}]{{/required}}{{^required}} = None{{/required}} {{#description}} """ {{{.}}} """ {{/description}} diff --git a/tests/CTS/client/ingestion/api.json b/tests/CTS/client/ingestion/api.json index f0ec2abdc5..b5c9f063cf 100644 --- a/tests/CTS/client/ingestion/api.json +++ b/tests/CTS/client/ingestion/api.json @@ -102,7 +102,9 @@ }, "expected": { "type": "response", - "match": {"message":"OK"} + "match": { + "message": "OK" + } } } ]