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

PathParameter attribute on an int parameter generates schema with incorrect 'int' type #1287

Open
bart-stiply opened this issue Jul 8, 2022 · 3 comments
Labels
bug type handling Type handling / mapping

Comments

@bart-stiply
Copy link

bart-stiply commented Jul 8, 2022

When I use the following attributes:

/**
   * Get user with provided id
   */
#[Get('/2.0/controller/{id}')]
#[OA\Get(path:'/2.0/controller/{id}', tags: ['demo'])]
#[OA\Response(response: 200, description: 'User with provided id', content: new OA\JsonContent(type: UserResponse::class))]
public function get(
    #[OA\PathParameter(required: true)]
    int $id
) {
   ...
}

The following parameter is generated:

"parameters": [
  {
    "name": "id",
    "in": "path",
    "required": true,
    "schema": {
      "type": "int"
    }
  }
],

I expect the type to be integer:

"parameters": [
  {
    "name": "id",
    "in": "path",
    "required": true,
    "schema": {
      "type": "integer"
    }
  }
],

As a workaround the type can be set explicitly in the PathParameter attribute:

#[OA\PathParameter(required: true, schema: new OA\Schema(type: 'integer'))]
@DerManoMann DerManoMann added the bug label Jul 9, 2022
@DerManoMann
Copy link
Collaborator

Yes this is a bug.

The whole type logic is up for refactoring but that does take some time so you'll have to be patient I am afraid.

@joelkohler
Copy link

When this will be fixed?

@DerManoMann
Copy link
Collaborator

Sigh - I should be back to this in the next few days. By back I probably mean 'startin again..' as its been a while and I did hit a wall in my attempts so far.
Having said that I have some more ideas now so hopefully something will stick.

@DerManoMann DerManoMann added the type handling Type handling / mapping label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug type handling Type handling / mapping
Projects
None yet
Development

No branches or pull requests

3 participants