-
Notifications
You must be signed in to change notification settings - Fork 84
IBX-8190: Update REST new resource #2682
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
base: 5.0
Are you sure you want to change the base?
Conversation
Preview of modified Markdown: |
out of scope
out of scope
Fix the following for low coast Parameter #1 $string of function substr expects string, string|false given.
Try to avoid "Call to function is_array() with array will always evaluate to true."
if ('json' === $format) { | ||
$data = $data[array_key_first($data)]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unwrap JSON.
I could even test that 'GreetingInput' === array_key_first($data)
code_samples/api/rest_api/src/Rest/Serializer/GreetingInputDenormalizer.php
Show resolved
Hide resolved
# Conflicts: # code_samples/api/rest_api/src/Rest/InputParser/GreetingInput.php # phpstan-baseline.neon
Preview of modified filesPreview of modified Markdown: |
`Compile Error: Declaration of App\Rest\Serializer\GreetingInputDenormalizer::denormalize(mixed $data, string $type, ?string $format = null, array $context = []) must be compatible with Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed`
`Compile Error: Declaration of App\Rest\Serializer\GreetingInputDenormalizer::supportsDenormalization(mixed $data, string $type, ?string $format = null): bool must be compatible with Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool`
`Error: Class App\Rest\Serializer\GreetingInputDenormalizer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Serializer\Normalizer\DenormalizerInterface::getSupportedTypes)`
`Compile Error: Declaration of App\Rest\Serializer\GreetingNormalizer::normalize(mixed $object, ?string $format = null, array $context = []): mixed must be compatible with Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize(mixed $data, ?string $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null`
`Compile Error: Declaration of App\Rest\Serializer\GreetingNormalizer::supportsNormalization(mixed $data, ?string $format = null) must be compatible with Symfony\Component\Serializer\Normalizer\NormalizerInterface::supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool`
`Error: Class App\Rest\Serializer\GreetingNormalizer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Serializer\Normalizer\NormalizerInterface::getSupportedTypes)`
code_samples/ change report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To myself: fix error found by redocly lint
.
'properties' => [ | ||
'salutation' => [ | ||
'type' => 'string', | ||
'required' => false, | ||
], | ||
'recipient' => [ | ||
'type' => 'string', | ||
'required' => false, | ||
], | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right way to declare property's mandatoriness.
Spec example: https://swagger.io/specification/#simple-model
[1] openapi.yaml:206:29 at #/paths/~1greet/post/requestBody/content/application~1vnd.ibexa.api.GreetingInput+xml/schema/properties/salutation/required
Expected type `array` but got `boolean`.
204 | salutation:
205 | type: string
206 | required: false
| ^^^^^
207 | recipient:
208 | type: string
Error was generated by the struct rule.
[2] openapi.yaml:209:29 at #/paths/~1greet/post/requestBody/content/application~1vnd.ibexa.api.GreetingInput+xml/schema/properties/recipient/required
Expected type `array` but got `boolean`.
207 | recipient:
208 | type: string
209 | required: false
| ^^^^^
210 | example:
211 | salutation: 'Good morning'
Error was generated by the struct rule.
'properties' => [ | |
'salutation' => [ | |
'type' => 'string', | |
'required' => false, | |
], | |
'recipient' => [ | |
'type' => 'string', | |
'required' => false, | |
], | |
], | |
'required' => [], | |
'properties' => [ | |
'salutation' => [ | |
'type' => 'string', | |
], | |
'recipient' => [ | |
'type' => 'string', | |
], | |
], |
'properties' => [ | ||
'salutation' => [ | ||
'type' => 'string', | ||
'required' => false, | ||
], | ||
'recipient' => [ | ||
'type' => 'string', | ||
'required' => false, | ||
], | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[3] openapi.yaml:218:71 at #/paths/~1greet/post/requestBody/content/application~1vnd.ibexa.api.GreetingInput+json/schema/properties/GreetingInput/properties/salutation/required
Expected type `array` but got `boolean`.
216 | GreetingInput:
217 | type: object
218 | properties: { salutation: { type: string, required: false }, recipient: { type: string, required: false } }
| ^^^^^
219 | example:
220 | GreetingInput:
Error was generated by the struct rule.
[4] openapi.yaml:218:117 at #/paths/~1greet/post/requestBody/content/application~1vnd.ibexa.api.GreetingInput+json/schema/properties/GreetingInput/properties/recipient/required
Expected type `array` but got `boolean`.
216 | GreetingInput:
217 | type: object
218 | properties: { salutation: { type: string, required: false }, recipient: { type: string, required: false } }
| ^^^^^
219 | example:
220 | GreetingInput:
Error was generated by the struct rule.
'properties' => [ | |
'salutation' => [ | |
'type' => 'string', | |
'required' => false, | |
], | |
'recipient' => [ | |
'type' => 'string', | |
'required' => false, | |
], | |
], | |
'required' => [], | |
'properties' => [ | |
'salutation' => [ | |
'type' => 'string', | |
], | |
'recipient' => [ | |
'type' => 'string', | |
], | |
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters: [ | ||
new Model\Parameter( | ||
name: 'Accept', | ||
in: 'header', | ||
required: false, | ||
description: 'If set, the greeting is returned in XML or JSON format.', | ||
schema: [ | ||
'type' => 'string', | ||
], | ||
example: 'application/vnd.ibexa.api.Greeting+json', | ||
), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters: [ | |
new Model\Parameter( | |
name: 'Accept', | |
in: 'header', | |
required: false, | |
description: 'If set, the greeting is returned in XML or JSON format.', | |
schema: [ | |
'type' => 'string', | |
], | |
example: 'application/vnd.ibexa.api.Greeting+json', | |
), | |
], | |
parameters: [], |
parameters: [ | ||
new Model\Parameter( | ||
name: 'Content-Type', | ||
in: 'header', | ||
required: false, | ||
description: 'The greeting input schema encoded in XML or JSON.', | ||
schema: [ | ||
'type' => 'string', | ||
], | ||
example: 'application/vnd.ibexa.api.GreetingInput+json', | ||
), | ||
new Model\Parameter( | ||
name: 'Accept', | ||
in: 'header', | ||
required: false, | ||
description: 'If set, the greeting is returned in XML or JSON format.', | ||
schema: [ | ||
'type' => 'string', | ||
], | ||
example: 'application/vnd.ibexa.api.Greeting+json', | ||
), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters: [ | |
new Model\Parameter( | |
name: 'Content-Type', | |
in: 'header', | |
required: false, | |
description: 'The greeting input schema encoded in XML or JSON.', | |
schema: [ | |
'type' => 'string', | |
], | |
example: 'application/vnd.ibexa.api.GreetingInput+json', | |
), | |
new Model\Parameter( | |
name: 'Accept', | |
in: 'header', | |
required: false, | |
description: 'If set, the greeting is returned in XML or JSON format.', | |
schema: [ | |
'type' => 'string', | |
], | |
example: 'application/vnd.ibexa.api.Greeting+json', | |
), | |
], | |
parameters: [], |
GET /greet
andPOST /greet
to schema/doc (/api/ibexa/v2/doc#/App/api_greet_get
).Preview: Creating new REST resource
Checklist