Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema properties not being set in the proper place for schema validation #41

Closed
derTuca opened this issue Sep 29, 2023 · 0 comments
Closed

Comments

@derTuca
Copy link

derTuca commented Sep 29, 2023

Hi! I have the following Elysia request:

.get('/:id', (c) => getEventDeploy(c.params.id, c.headers), {
    params: getDeployParamsSchema,
    detail: {
      summary: 'Returns the progress entries for the event with the given id.'
    },
    type: 'application/json'
  })

The Swagger generator generates an invalid entry for this request by default and the validation errors are as follows:

     "get": {
        "parameters": [
          {
            "pattern": "^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$",
            "default": "",
            "description": "The event id to get logs for",
            "type": "string",
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "operationId": "getById",
        "summary": "Returns the progress entries for the event with the given id.",
        "responses": { "200": {} }
      }

image

In order to get a properly validated parameters object, I have to specify the following manually in parameters:

.get('/:id', (c) => getEventDeploy(c.params.id, c.headers), {
    params: getDeployParamsSchema,
    detail: {
      summary: 'Returns the progress entries for the event with the given id.',
      parameters: [
        {
          schema: getDeployParamsSchema.properties.id,
          name: 'id',
          in: 'path',
          required: true
        }
      ]
    },
    type: 'application/json'
  })

This generates the following schema, which does not error out at param validation:
image

Should this (generating the schema object for each param) not be the default behavior? Thanks!

SaltyAom added a commit that referenced this issue Oct 27, 2023
fix: parameters mapping, fix #41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant