opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
359 stars 178 forks source link

Enhanced the generator to omit generating default parameter values when already present in param description. #731

Closed saimedhi closed 6 months ago

saimedhi commented 6 months ago

Description

Issues Resolved

Closes https://github.com/opensearch-project/opensearch-py/pull/727#discussion_r1573170642

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

dblock commented 6 months ago

Shouldn't the spec not include the default in the description instead if it has an x-default... field (because they can effectively disagree).

saimedhi commented 6 months ago

Shouldn't the spec not include the default in the description instead if it has an x-default... field (because they can effectively disagree).

Example 1:

reindex::query.wait_for_active_shards:
  in: query
  name: wait_for_active_shards
  description: |-
    The number of shard copies that must be active before proceeding with the operation.
    Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas + 1`).
  schema:
    $ref: '#/components/schemas/_common:WaitForActiveShards'
  style: form
  x-default: '1'

Example 2:

reindex::query.wait_for_completion:
  in: query
  name: wait_for_completion
  description: If `true`, the request blocks until the operation is complete.
  schema:
    type: boolean
    default: true       
  style: form
dblock commented 6 months ago

@saimedhi Open an issue in opensearch-api-specification to move any "default is ..." to schema or x-default and possibly add a linter. Also don't let @nhtruong beat you to picking up and implementing it ;)