Comments (10)
Yes correct. I will try and find some time somewhere soon to see if I can fix this. If I manage to fix this then a patch will be released for this most likely.
from nelmioapidocbundle.
Good news, I managed to fix it in https://github.com/nelmio/NelmioApiDocBundle/releases/tag/v4.19.3 😄
from nelmioapidocbundle.
Installing the specific 4.17.*
version via composer seems to solve the problem, so it must be a recent update:
{
...
"require": {
...
"nelmio/api-doc-bundle": "4.17.*",
...
},
...
}
Lock file operations: 0 installs, 1 update, 0 removals
- Downgrading nelmio/api-doc-bundle (v4.19.2 => v4.18.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downloading nelmio/api-doc-bundle (v4.18.3)
- Downgrading nelmio/api-doc-bundle (v4.19.2 => v4.18.3): Extracting archive
Lock file operations: 0 installs, 1 update, 0 removals
- Downgrading nelmio/api-doc-bundle (v4.18.3 => v4.17.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downloading nelmio/api-doc-bundle (v4.17.1)
- Downgrading nelmio/api-doc-bundle (v4.18.3 => v4.17.1): Extracting archive
from nelmioapidocbundle.
Could you share how your CreateUserController
__invoke
method looks? I assume you are using Symfony's MapRequestPayload
attribute there, which I think is causing the issue.
from nelmioapidocbundle.
Yes, it is a Symfony project, and I am using the MapRequestPayload
attribute to map the JSON key-value pairs after built-in validation.
The ContentType::APPLICATION_JSON
constant equals to application/json
.
The Controller's __invoke
method has the following attributes (each OA\MediaType
belongs to its own OA\Response
with different status codes, as you can see):
#[Route(path: '/api/v3/users', name: 'api_v3_users_create', methods: [Request::METHOD_POST])]
#[Nelmio\Security(name: null)]
#[OA\RequestBody(
content: new OA\MediaType(mediaType: ContentType::APPLICATION_JSON, schema: new OA\Schema(
ref: new Nelmio\Model(type: CreateUserRequestDto::class),
)),
)]
#[OA\Response(
response: Response::HTTP_CREATED,
description: 'Created. New entity created successfully',
content: new OA\MediaType(mediaType: ContentType::APPLICATION_JSON, schema: new OA\Schema(
ref: new Nelmio\Model(type: UserEntity::class, groups: ['AtTag', 'MyUserData']),
)),
)]
#[OA\Response(
response: Response::HTTP_UNSUPPORTED_MEDIA_TYPE,
description: 'Unsupported Media Type. Expected "Content-Type: application/json" header not provided',
content: new OA\MediaType(mediaType: ContentType::APPLICATION_JSON, schema: new OA\Schema(properties: [
new OA\Property(property: 'code', type: 'integer', example: Response::HTTP_UNSUPPORTED_MEDIA_TYPE),
new OA\Property(property: 'error', type: 'string', example: 'Unsupported Media Type'),
new OA\Property(property: 'message', type: 'string'),
])),
)]
#[OA\Response(
response: Response::HTTP_UNPROCESSABLE_ENTITY,
description: 'Unprocessable Content. The provided JSON Payload is invalid',
content: new OA\MediaType(mediaType: ContentType::APPLICATION_JSON, schema: new OA\Schema(properties: [
new OA\Property(property: 'code', type: 'integer', example: Response::HTTP_UNPROCESSABLE_ENTITY),
new OA\Property(property: 'error', type: 'string', example: 'Unprocessable Content'),
new OA\Property(property: 'message', type: 'string'),
])),
)]
public function __invoke(#[MapRequestPayload] CreateUserRequestDto $requestDTO): JsonResponse
from nelmioapidocbundle.
Hey, @DjordyKoert,
I wondered if the attributes I added in my last comment were helpful. I'm not pushing or rushing for an update (in the end, this is an open-source repo), but it would be nice to get an update, if any, or in case I could provide more details.
Thanks,
from nelmioapidocbundle.
Hey @DavidGarciaCat sorry for not responding 😅
The information you provided is plenty because I am pretty sure that the issue is caused because of the #[MapRequestPayload]
attribute which Nelmio attempts to describe for you.
I think the quick-fix on your end could be to remove the usage #[OA\RequestBody]
attribute (or remove the content:
param in case you still want to provide a description or something similair for you request body) because. It will still generate a valid api documentation for you endpoint which includes the request body for your endpoint.
from nelmioapidocbundle.
Thanks for the quick response, @DjordyKoert,
If I understood you correctly, this would be a temporary fix to upgrade the bundle and keep rendering the documentation. Still, another minor/patch release will be necessary to fix the exception - am I right here?
Once again, thanks for the quick response.
from nelmioapidocbundle.
Much appreciated for the update - enjoy the rest of your week!
from nelmioapidocbundle.
Thanks for the update, @DjordyKoert - Enjoy the rest of your week!
from nelmioapidocbundle.
Related Issues (20)
- Required field in OpenAPI response HOT 1
- Error with Model Attribute HOT 6
- @OA\Items() is required when @OA\Property HOT 7
- [Bug]: Swagger assets ignore X-Forwarded-Prefix header value HOT 2
- [Question]: DocumentExtension not getting loaded in Test context HOT 3
- [Bug]: 'Type' Expected, given string when using 'ref: new Model(type: Entity::class)' in attribute HOT 2
- incorrect server url in openapi document when behind reverse proxy HOT 1
- [Bug]: Not all integer range types supported HOT 3
- [Bug]: Object of class Nelmio\ApiDocBundle\Annotation\Model could not be converted to string HOT 4
- [Bug]: Assert\NotBlank is considered regardless of it's group values HOT 1
- [Question]: Discriminator schema with Doctrine ORM Discriminator map HOT 2
- [Feature]: Webhook support
- [RFC]: Adopt Conventional Commits HOT 1
- [Question]: Is it possible to view a web form when mediaType is "application/json"? HOT 2
- [Feature]: FOSRestBundle QueryParam AND nelmio_api_doc.yaml
- [Feature]: FOSRestBundle QueryParam AND nelmio_api_doc.yaml
- [Bug]: @OA\Property excludes property from model's required array HOT 2
- [Bug]: Lost data format in schema for array of objects HOT 1
- [Feature]: Describing default error response
- [Question]: Code breaks after updating from 4.25.2 to 4.25.3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nelmioapidocbundle.