Skip to content

openapi: decide whether an extension mapping with non-string keys is kept with its keys stringified #617

Closed

Description

@OmarAlJarrah

Problem

A vendor extension whose value is a YAML mapping with integer or boolean keys, a common shape for naming the members of an integer enum, is dropped whole:

Level:
  type: integer
  enum: [1, 2]
  x-member-names: {1: Low, 2: High}
warning openapi/degraded-construct …: extension "x-member-names" could not be serialized

This is deliberate today: compilers/openapi/unpreservable_test.go lists a non-string key as one of the two reachable ways a preserved payload fails to convert. The consequence is that Unmodeled's losslessness depends on the key type, for a construct that is plain, valid YAML.

Options

  • Keep the drop, as today.
  • Stringify scalar keys when converting to JSON (1 → "1"), and record that the conversion happened, so a consumer that cares can tell.

Related: #245.

Activity

  1. added
    priority:P3Later emitters, M4 and up, 3.2-only, streaming, webhooks, rare constructs
    priority:P4Refactors, tests, CI, hostile-input hardening, cosmetic diagnostics, other formats
    and removed
    priority:P3Later emitters, M4 and up, 3.2-only, streaming, webhooks, rare constructs
    on Oct 19, 2026
  2. OmarAlJarrah commented on Oct 23, 2026

    @OmarAlJarrah
    MemberAuthor

    #1106 decides this for the second option, without a marker. A scalar key is kept as the text it spells ({"1": "Low", "2": "High"}), in an extension and in every other verbatim payload.

    No marker records a conversion because, under the specification's reading, none happens: the Format section limits a key used in a YAML map to a scalar string as the YAML Failsafe schema defines it, and under that schema 1 is the string "1". The parser reads every key that way too. A key that is no scalar, a mapping or a list written as a key, is another matter: the parser reads it as the empty string, so the compiler does the same and reports the key as an error (openapi/validation/validation-type-mismatch).

    The rule is verbatim-preservation once #1106 lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P4Refactors, tests, CI, hostile-input hardening, cosmetic diagnostics, other formatstype:featureNew capability or enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions