elastic / elasticsearch-specification

Elasticsearch full specification
Apache License 2.0
111 stars 68 forks source link

OpenAPI spec generation: support bullets in descriptions (stop escaping `\n`) #2710

Closed shainaraskas closed 2 weeks ago

shainaraskas commented 3 weeks ago

🚀 Feature Proposal

we can add bullets to descriptions in bump.sh by passing the following markup in our JSON openAPI spec file:

"description": "Converts an index alias to a data stream. You must have a matching index template that is data stream enabled. The alias must meet the following criteria:\n - The alias must have a write index.\n - All indices for the alias must have a `@timestamp` field mapping of a `date` or `date_nanos` field type.\n - The alias must not have any filters.\n - The alias must not use custom routing.\n\n If successful, the request removes the alias and creates a data stream with the same name. The indices for the alias become hidden backing indices for the stream. The write index for the alias becomes the write index for the stream.",
Screenshot 2024-07-11 at 5 03 14 PM

our openapi spec generator (make generate or make transform-to-openapi) escapes backslashes, breaking newline characters we need to format the list.

input:

/**
 * Convert an index alias to a data stream.
 * Converts an index alias to a data stream.
 * You must have a matching index template that is data stream enabled.
 * The alias must meet the following criteria:\n
 * - The alias must have a write index.\n
 * - All indices for the alias must have a `@timestamp` field mapping of a `date` or `date_nanos` field type.\n
 * - The alias must not have any filters.\n
 * - The alias must not use custom routing.\n\n
 * If successful, the request removes the alias and creates a data stream with the same name.
 * The indices for the alias become hidden backing indices for the stream.
 * The write index for the alias becomes the write index for the stream.
 * @rest_spec_name indices.migrate_to_data_stream
 * @availability stack since=7.9.0 stability=stable
 * @availability serverless stability=stable visibility=public
 * @index_privileges manage
 */

output:

"description": "Converts an index alias to a data stream. You must have a matching index template that is data stream enabled. The alias must meet the following criteria:\\n - The alias must have a write index.\\n - All indices for the alias must have a `@timestamp` field mapping of a `date` or `date_nanos` field type.\\n - The alias must not have any filters.\\n - The alias must not use custom routing.\\n\\n If successful, the request removes the alias and creates a data stream with the same name. The indices for the alias become hidden backing indices for the stream. The write index for the alias becomes the write index for the stream.",

Motivation

We have a lot of descriptions where we need to present lists of information, and would have to hack around this using html if we couldn't get newlines working. currently we just skip bullets altogether:

Screenshot 2024-07-11 at 5 10 24 PM

Example

See above