Skip to content

defineRouteMeta needs to take a type parameter for examples value #2490

Description

@airtonix

Describe the feature


defineRouteMeta({
  openAPI: {
    tags: ["test"],
    description: "Test route description",
    requestBody: {
      required: true,
      content: {
        "application/json": {
          description: "Payload",
          summary: "Payload",
          schema: SomeInputSchemaJson,
          examples: {
            my_correct_example {
              summary: "an awesome example",
              value: {
                 yayValidField: 'nice'
              },
            },
            my_incorrect_example {
              summary: "oops",
              value: {
                 failTrain: 'lmao'
              },
            },
          },
        },
      },
    },
    responses: {
      "200": {
        summary: "Success",
        description: "Success",
        content: {
          "application/json": {
            encoding: {},
            schema: SomeOutputSchemaJson,
          },
        },
      },
    },
  },
});

Given the above route meta, we should be able to ensure that we get type safety when inserting incorrect example data structure :

defineRouteMeta<SomeInput>({
  openAPI: {
    tags: ["test"],
    description: "Test route description",
    requestBody: {
      required: true,
      content: {
        "application/json": {
          description: "Payload",
          summary: "Payload",
          schema: SomeInputSchemaJson,
          examples: {
            my_correct_example {
              summary: "an awesome example",
              value: {
                 yayValidField: 'nice'
              },
            },
            my_incorrect_example {
              summary: "oops",
              value: {
                 failTrain: 'lmao' 👈👈👈👈👈👈👈👈 should now show error
              },
            },
          },
        },
      },
    },
    responses: {
      "200": {
        summary: "Success",
        description: "Success",
        content: {
          "application/json": {
            encoding: {},
            schema: SomeOutputSchemaJson,
          },
        },
      },
    },
  },
});

Additional information

  • Would you be willing to help implement this feature?

Activity

  1. added
    pending triage
    on Jun 3, 2024
  2. added
    enhancement
    and removed
    pending triage
    on Sep 2, 2026
  3. added and removed on Oct 17, 2026
  4. added
    openapi
    types
    and removed
    enhancement
    on Nov 10, 2026
  5. added theissue type on Nov 10, 2026
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

    openapitypes

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions