Skip to content

Commit

Permalink
fix(specs): rules and objects parameters/responses (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Jul 28, 2022
1 parent 3900df0 commit 95ba001
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/.cache_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.10
0.0.11
19 changes: 12 additions & 7 deletions specs/common/schemas/IndexSettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,7 @@ indexSettingsAsSearchParams:
x-categories:
- Query strategy
distinct:
type: integer
minimum: 0
maximum: 4
description: Enables de-duplication or grouping of results.
default: 0
x-categories:
- Advanced
$ref: '#/distinct'
synonyms:
type: boolean
description: Whether to take into account an index's synonyms for a particular search.
Expand Down Expand Up @@ -425,6 +419,17 @@ advancedSyntaxFeatures:
x-categories:
- Query strategy

distinct:
description: Enables de-duplication or grouping of results.
oneOf:
- type: boolean
- type: integer
minimum: 0
maximum: 4
default: 0
x-categories:
- Advanced

typoTolerance:
description: Controls whether typo tolerance is enabled and how it is applied.
oneOf:
Expand Down
2 changes: 2 additions & 0 deletions specs/search/common/schemas/listIndicesResponse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ listIndicesResponse:
type: integer
description: Number of pages.
example: 100
required:
- items

fetchedIndex:
type: object
Expand Down
2 changes: 1 addition & 1 deletion specs/search/paths/objects/batch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ post:
requests:
type: array
items:
title: batchOperation
title: batchRequest
type: object
additionalProperties: false
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ post:
type: array
items:
description: getObjects operation on an index.
title: multipleGetObjectsParams
title: getObjectsRequest
type: object
additionalProperties: false
required:
Expand Down Expand Up @@ -55,6 +55,9 @@ post:
items:
type: object
description: Fetched object.
x-is-generic: true
required:
- results
'400':
$ref: '../../../common/responses/BadRequest.yml'
'402':
Expand Down
2 changes: 1 addition & 1 deletion specs/search/paths/objects/multipleBatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ post:
requests:
type: array
items:
title: multipleBatchOperation
title: multipleBatchRequest
type: object
additionalProperties: false
properties:
Expand Down
3 changes: 3 additions & 0 deletions specs/search/paths/objects/objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ post:
$ref: '../../../common/responses/common.yml#/taskID'
objectID:
$ref: '../../../common/parameters.yml#/objectID'
required:
- taskID
- createdAt
'400':
$ref: '../../../common/responses/BadRequest.yml'
'402':
Expand Down
6 changes: 6 additions & 0 deletions specs/search/paths/rules/common/schemas.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
rules:
type: array
description: Rules to add.
items:
$ref: '#/rule'

rule:
type: object
description: Rule object.
Expand Down
5 changes: 1 addition & 4 deletions specs/search/paths/rules/saveRules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ post:
content:
application/json:
schema:
type: array
description: Rules to add.
items:
$ref: 'common/schemas.yml#/rule'
$ref: 'common/schemas.yml#/rules'
responses:
'200':
$ref: '../../../common/responses/UpdatedAt.yml'
Expand Down
2 changes: 1 addition & 1 deletion specs/search/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ paths:
/1/indexes/*/batch:
$ref: 'paths/objects/multipleBatch.yml'
/1/indexes/*/objects:
$ref: 'paths/objects/multipleGetObjects.yml'
$ref: 'paths/objects/getObjects.yml'

# ##########################
# ### Settings Endpoints ###
Expand Down
20 changes: 20 additions & 0 deletions templates/javascript/clients/client/model/types/dataType.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{! possible data types of a parameter }}
{{#isEnum}}
{{classname}}{{{nameInCamelCase}}}{{#isArray}}[]{{/isArray}}
{{/isEnum}}
{{^isEnum}}
{{#x-propagated-generic}}
{{> client/model/types/dataTypeGeneric}}
{{/x-propagated-generic}}
{{^x-propagated-generic}}
{{#x-has-child-generic}}
{{> client/model/types/dataTypeGeneric}}
{{/x-has-child-generic}}
{{^x-has-child-generic}}
{{{dataType}}}
{{/x-has-child-generic}}
{{/x-propagated-generic}}
{{#isNullable}}
| null
{{/isNullable}}
{{/isEnum}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{#complexType}}{{{.}}}<T>{{/complexType}}{{^complexType}}T{{/complexType}}{{#isArray}}[]{{/isArray}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{! parameter that is generic and have a default value }}
{{#vendorExtensions.x-has-child-generic}}
<T = Record<string, any>>
{{/vendorExtensions.x-has-child-generic}}
{{#vendorExtensions.x-is-generic}}
<T = Record<string, any>>
{{/vendorExtensions.x-is-generic}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{! Parameter that is generic and propagates it to its child }}
{{#vendorExtensions.x-has-child-generic}}<T>{{/vendorExtensions.x-has-child-generic}}
13 changes: 4 additions & 9 deletions templates/javascript/clients/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,20 @@ import { {{classname}} } from '{{filename}}';
/**
* {{{description}}}
*/{{/description}}
export type {{classname}}{{#vendorExtensions.x-has-child-generic}}<T>{{/vendorExtensions.x-has-child-generic}} = {{#composedSchemas.oneOf}}{{{dataType}}}{{#vendorExtensions.x-has-child-generic}}<T>{{/vendorExtensions.x-has-child-generic}} {{^-last}}|{{/-last}} {{/composedSchemas.oneOf}}
{{#composedSchemas.allOf}}{{{dataType}}}{{#vendorExtensions.x-has-child-generic}}<T>{{/vendorExtensions.x-has-child-generic}} {{^-last}}&{{/-last}} {{/composedSchemas.allOf}};
export type {{classname}}{{> client/model/types/isGeneric}} = {{#composedSchemas.oneOf}}{{{dataType}}}{{> client/model/types/propagateGeneric}} {{^-last}}|{{/-last}} {{/composedSchemas.oneOf}}{{#composedSchemas.allOf}}{{{dataType}}}{{> client/model/types/propagateGeneric}} {{^-last}}&{{/-last}} {{/composedSchemas.allOf}};
{{/interfaces.size}}{{^interfaces.size}}
{{#description}}
/**
* {{{description}}}
*/{{/description}}{{^isEnum}}
export type {{classname}}{{#vendorExtensions.x-is-generic}}<T>{{/vendorExtensions.x-is-generic}}{{#vendorExtensions.x-has-child-generic}}<T>{{/vendorExtensions.x-has-child-generic}} = {{^vendorExtensions.x-is-generic}}{{#parent}}{{{.}}} & {{/parent}}{{/vendorExtensions.x-is-generic}}{{#vendorExtensions.x-is-generic}}T & {{/vendorExtensions.x-is-generic}} {
export type {{classname}}{{> client/model/types/isGeneric}} = {{^vendorExtensions.x-is-generic}}{{#parent}}{{{.}}} & {{/parent}}{{/vendorExtensions.x-is-generic}}{{#vendorExtensions.x-is-generic}}T & {{/vendorExtensions.x-is-generic}} {
{{#vendorExtensions}}
{{#vars}}{{#description}}
/**
* {{{description}}}
*/{{/description}}
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{classname}}{{{nameInCamelCase}}}{{#isArray}}[]{{/isArray}}{{/isEnum}}
{{^isEnum}}{{#x-propagated-generic}}{{{complexType}}}<T>{{#isArray}}[]{{/isArray}}{{/x-propagated-generic}}
{{^x-propagated-generic}}
{{#x-has-child-generic}}{{{complexType}}}<T>{{#isArray}}[]{{/isArray}}{{/x-has-child-generic}}
{{^x-has-child-generic}}{{{dataType}}}{{/x-has-child-generic}}
{{/x-propagated-generic}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};{{/vars}}
{{name}}{{^required}}?{{/required}}: {{> client/model/types/dataType}} ;
{{/vars}}
} {{#x-is-SearchForHitsOptions}} & { facet?: never; maxFacetHits?: never; facetQuery?: never }; {{/x-is-SearchForHitsOptions}}
{{/vendorExtensions}}
{{/isEnum}}
Expand Down
40 changes: 40 additions & 0 deletions tests/CTS/methods/requests/search/setSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,46 @@
}
}
},
{
"testName": "setSettings allow boolean `distinct`",
"parameters": {
"indexName": "theIndexName",
"indexSettings": {
"distinct": true
},
"forwardToReplicas": true
},
"request": {
"path": "/1/indexes/theIndexName/settings",
"method": "PUT",
"body": {
"distinct": true
},
"queryParameters": {
"forwardToReplicas": "true"
}
}
},
{
"testName": "setSettings allow integers for `distinct`",
"parameters": {
"indexName": "theIndexName",
"indexSettings": {
"distinct": 1
},
"forwardToReplicas": true
},
"request": {
"path": "/1/indexes/theIndexName/settings",
"method": "PUT",
"body": {
"distinct": 1
},
"queryParameters": {
"forwardToReplicas": "true"
}
}
},
{
"testName": "setSettings allow all `indexSettings`",
"parameters": {
Expand Down

0 comments on commit 95ba001

Please sign in to comment.