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

Missing type definition for header when using #/components/parameters/... syntax in the schema #1790

Closed
DefCon-007 opened this issue Jan 7, 2025 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@DefCon-007
Copy link
Contributor

What are the steps to reproduce this issue?

  1. Use the following OpenAPI schema.
{
    "openapi": "3.0.0",
    "info": {
      "title": "Simple API",
      "version": "1.0.0"
    },
    "paths": {
      "/example": {
        "get": {
          "summary": "Retrieve example data",
          "parameters": [
            {
              "$ref": "#/components/parameters/stackId"
            }
          ],
          "responses": {
            "200": {
              "description": "Successful response",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "object",
                    "properties": {
                      "message": {
                        "type": "string",
                        "example": "Hello, World!"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "components": {
      "parameters": {
        "stackId": {
          "in": "header",
          "name": "X-Stack-Id",
          "schema": {
            "type": "integer"
          },
          "required": true
        }
      }
    }
  }
  1. Check the type definition of headers, it will be something like follows
export type GetExampleStackIdHeaders = {
  "X-Stack-Id": HeaderStackIdParameter;
};
  1. You will notice that the HeaderStackIdParameter type is not generated at all.

What happens?

The generated type definition is incomplete when a simple header parameter is referenced using the #/components/parameters/... syntax.

What were you expecting to happen?

Correct type definitions to be generated

Any logs, error output, etc?

Any other comments?

What versions are you using?

  System:
    OS: macOS 15.2
    CPU: (14) arm64 Apple M3 Max
    Memory: 422.19 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
DefCon-007 added a commit to DefCon-007/orval that referenced this issue Jan 7, 2025
If the header parameter is defined using the #/components/parameters/... syntax, then an incomplete type definition is generated for the headers, this fixes the behaviour by adding the missing types.

Fix orval-labs#1790
@DefCon-007
Copy link
Contributor Author

Closing as duplicate of #878

@melloware melloware added this to the 7.3.1 milestone Jan 7, 2025
@melloware melloware added the bug Something isn't working label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants