elastic / enterprise-search-js

Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.
https://www.elastic.co/guide/en/enterprise-search-clients/index.html
Apache License 2.0
2 stars 10 forks source link

app.putSchema() schema param types do not match the documentation #41

Closed C3nE3s closed 1 year ago

C3nE3s commented 1 year ago

🐛 Bug Report

The provided typescript types for the schema property in the params object for client.app.putSchema() do not match the example provided in the documentation.

To Reproduce

async function run () {
  const schemaUpdate = await client.app.putSchema(
    {engine_name: 'national-parks',
    schema: {date_established: 'date'}})
  if (schemaUpdate.errors) {
    console.log(schemaUpdate)
    process.exit(1)
  }
  console.log(schemaUpdate)}

run().catch(console.error)

Expected behavior

The provided type for the param property schema is as follows:

schema?:  {
        [k: string]: {
            [k: string]: unknown;
        };
    };

This requires nested object structure while the documentation demonstrates a flat object. I assume this typing is off, but if not, I would expect the example to reflect why the schema object shape is something other than a Record<string,unknown>

ricokareem commented 1 year ago

@TattdCodeMonkey @delvedor @leemthompo I know this is really low-hanging fruit, but just bumping the above PR, unless you see this as a breaking change. Thanks in advance.

TattdCodeMonkey commented 1 year ago

@ricokareem sorry for the late response.

This client is generated from an OpenAPI spec and it appears this type is not being generated correctly based on that spec. I will investigate that and see if I can resolve this in the next release.