Mintlify ignores the JSON Schema examples keyword when generating request code samples #6654
jeremycohensolal-paylead
started this conversation in
Bugs & Feedback
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Bug report: Mintlify ignores the JSON Schema
exampleskeyword when generating request code samplesSummary
When Mintlify generates the request code samples (cURL / Python / JavaScript) shown on an
OpenAPI operation page, it reads only the singular, deprecated
examplekeyword on aSchema Object property. It ignores the plural, standard
exampleskeyword (JSON Schema2020-12) unless the property happens to sit inside an
anyOf/oneOf.The practical consequences:
examples(plural) renders as a placeholder(
"<string>") instead of its example value.enumproperty whose only example metadata isexamples(plural) is droppedentirely from the generated body — even when it is
required. The sample then omits amandatory field, so a user who copies it produces an invalid request.
This is backwards relative to the specifications:
example(singular) is deprecated inOpenAPI 3.1, and
examples(plural array) is the standard JSON Schema 2020-12 keyword —and it is exactly the form emitted by common generators such as Pydantic v2
(
Field(examples=[...])).Environment
mint dev.3.1.0(Schema Object is a superset of JSON Schema 2020-12).example/examples, so the sample issynthesized entirely from per-property schema metadata (this is what isolates the bug).
Minimal reproduction
1. A complete, self-contained OpenAPI 3.1 spec
Four properties, all
string, allrequired. They differ only by which example keywordthey use. Save as
repro.json(or.yaml).{ "openapi": "3.1.0", "info": { "title": "Example keyword repro", "version": "1.0.0" }, "servers": [{ "url": "https://api.example.com" }], "paths": { "/demo": { "post": { "summary": "Reproduce example vs examples", "operationId": "demo_repro", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Demo" } } } }, "responses": { "200": { "description": "OK" } } } } }, "components": { "schemas": { "Demo": { "type": "object", "required": ["with_example", "with_examples", "enum_example", "enum_examples"], "properties": { "with_example": { "type": "string", "example": "HELLO" }, "with_examples": { "type": "string", "examples": ["HELLO"] }, "enum_example": { "type": "string", "enum": ["a", "b", "c"], "example": "a" }, "enum_examples": { "type": "string", "enum": ["a", "b", "c"], "examples": ["a"] } } } } } }2. Render it
Reference the spec from
docs.jsonand start the dev server:mint dev # or: mintlify devOpen the generated operation page and read the cURL sample in the right-hand panel.
3. Observed output (verbatim, captured from
mint dev){ "with_example": "HELLO", "with_examples": "<string>", "enum_example": "a" }4. Expected output
{ "with_example": "HELLO", "with_examples": "HELLO", "enum_example": "a", "enum_examples": "a" }What this proves
with_exampleexample(singular)"HELLO"with_examplesexamples(plural)"<string>"enum_exampleexample(singular)"a"enum_examplesexamples(plural)with_exampleandwith_examplesare byte-for-byte identical except for the keyword name andcarry the same value — so the only variable explaining the difference is the keyword itself.
enum_examplesdisappears from the payload entirely, which is the more damaging case: thegenerated sample silently omits a
requiredfield.Additional observed behavior (same test method)
For completeness, the full behavior matrix we verified:
examples(plural) on a bare property → ignored (placeholder).examples(plural) on a property insideanyOf/oneOf→ honored (Mintlify'sunion preprocessing copies
examples[0]into each branch as a singularexample). This iswhy nullable properties (
anyOf: [{...}, {"type": "null"}]) render their examples but plainones do not — an internal inconsistency.
example(singular) as a sibling of a$ref, or placed directly on the referencedcomponent schema → honored.
enumproperty with no derivable singularexample/default→ omitted from thesample (not placeholdered), required or not.
default→ honored.Why this is a bug (standards references)
OpenAPI 3.1 defines the Schema Object as "a superset of the JSON Schema Specification Draft
2020-12", and JSON Schema 2020-12 provides the
exampleskeyword:The singular
examplekeyword on the Schema Object is deprecated in OpenAPI 3.1:So Mintlify currently honors the deprecated form and ignores the standard, recommended
form for Schema Object properties. Tooling that follows the spec — e.g. Pydantic v2, which
emits
Field(examples=[...])→"examples": [...]— produces samples that are wrong orincomplete in Mintlify.
Impact
<string>placeholders where real values wereprovided, and silently omit required enum-typed fields — users send invalid requests.
JSON Schema 2020-12) are affected out of the box, with no authoring mistake on the API side.
Workarounds (until fixed upstream)
examples[0]into a sibling singularexampleon every schema property(keep the plural array for spec correctness). This is the minimal, spec-compatible fix and
is what unblocks the samples today.
enumproperties, ensure a singularexampleis derivable — set it on the referencedcomponent schema so one edit covers every referencing property.
requestBody.content["application/json"].exampleoverrides the synthesized sample entirely.References
example, deprecation note):https://spec.openapis.org/oas/v3.1.0.html#schema-object
https://spec.openapis.org/oas/v3.1.0.html#data-types
examples:https://json-schema.org/draft/2020-12/json-schema-validation#name-examples
default):https://github.com/orgs/mintlify/discussions/759
All reactions