-
-
Notifications
You must be signed in to change notification settings - Fork 965
ApiResource parameters denormalizationContext and normalizationContext doesn't affect #1892
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
Comments
I have the same issus, but if you checked the respenses schemas |
Same problem here, downgrading to 2.6.3 works |
I feel a bit relieved that i'm not the only one facing this issue. i've opened a bug here but i think it's the wrong place for it. |
for what it's worth the controllers seem to be working just fine, the only real problem is the swagger UI displaying the wrong schema |
No, if you send for example password field which not showed in swagger then api-platfoem ignores it |
Same problem here |
just to follow! |
same problem |
Btw, if anyone wants to do some digging, since the problem occurs between 2.6.3 and 2.6.4, here is the diff: api-platform/core@v2.6.3...v2.6.4 From that diff, api-platform/core#4138 looks particularly interesting. If someone having this issue could try to "revert" that PR manually on their local copy... to see if it makes any difference, that might help things :). Cheers! |
Indeed, several issues popped up after api-platform/core#4138 (more precisely the commit "Improve openapi performances"), for which the latest fix is api-platform/core#4247 |
Swagger display the wrong schema in the method but the controller still follow the right schema that is created with normalizationContext and denormalizationContext |
Same issue here, everything still works fine in the backend but the Swagger/ReDoc is not using the denormalization context data to show the right parameters. |
PS: v2.6.5 this is still not fixed |
Then this might be related to api-platform/core#4248 (or not) |
How they not see yet this bug? |
I don't see the bug anymore in 2.6.5. |
@alanpoulain I can confirm that the different issues I had around this problem have been fixed in 2.6.5 |
@alanpoulain I just setup new app but it hasn't been fixed 😕 Here is the entity code // App\Entity\Test
// .....
**
* @ORM\Entity(repositoryClass=TestRepository::class)
*/
#[ApiResource(
collectionOperations: ['get','post'],
itemOperations: [
'patch' => [
'denormalization_context' => ['groups' => ['write']]
]
],
denormalizationContext: ['groups' => ['create']],
normalizationContext: ['groups' => ['read']],
)]
class Test
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[Groups(['read'])]
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
#[Groups(['read','create','write'])]
private $prop1;
/**
* @ORM\Column(type="string", length=255)
*/
#[Groups(['create','write'])]
private $prop2;
/**
* @ORM\Column(type="string", length=255)
*/
#[Groups(['write'])]
private $prop3;
// ....
} |
Please make sure:
public function getId(): int
{
return $this->id;
}
public function getProp1(): string
{
return $this->prop1;
}
public function getProp2(): string
{
return $this->prop2;
}
public function getProp3(): string
{
return $this->prop3;
}
|
@alanpoulain yes it has getter & setter and I am using latest symfony version and version 2.6.5 of api platform |
Make sure you cache is cleared. |
that is a new project 😕 |
I've tested. Problem solved in 2.6.5! |
thanks @alanpoulain its fixed as you said 👍 |
Still have an issue with this example on Symfony 6 and version 2.6.8. textDescription field does not appears in Swagger documentation for write model.
|
3.0 rc2 also |
API Platform version(s) affected: 2.6.4
Everything ok when you downgrade to 2.6.3
Description
ApiResource parameters denormalizationContext and normalizationContext doesn't affect.
How to reproduce
In version 2.6.4 - swagger shows all fields and ignores denormalizationContext and normalizationContext
But In versions before that, for example 2.6.3 - everything is ok. Swagger shows considering denormalizationContext and normalizationContext goups
How swagger looks with ApiPlatform version 2.6.3

Same code with 2.6.4

Original file is there: https://github.com/kadirov/api-starter-kit/blob/master/src/Entity/User.php
Possible Solution
Downgrade to 2.6.3
Additional Context
Symfony version 5.2.6
PHP version 8.0.3
OS: tested on windows 10, Fedora 33, docker with Debian 10
The text was updated successfully, but these errors were encountered: