ubirak / symfony-json-rest-api Goto Github PK
View Code? Open in Web Editor NEWSymfony stuff to help building a json rest api without annotation
License: Apache License 2.0
Symfony stuff to help building a json rest api without annotation
License: Apache License 2.0
We should allow people to use this stuff with a better DX.
Copy/Paste is just a problem if we add/modify stuff
Hi,
I'm using Swagger to define Schema Objects which are based on the JSON Schema Specification Draft 4.
I have a standalone example that you can find here:
https://gist.github.com/jeremyb/a0419ad9d5501fb602f052169112166f
I'm curious to know if you might be interested to make symfony-json-rest-api
works with Swagger (not only with separate JSON Schema files).
Currently, I see some issues with the PayloadValidator
class (especially with $jsonSchemaFilename
: file_exists
and realpath
calls).
Also, we probably need to update JsonSchemaTools
to allow the creation from a SchemaStorage
?
Do you have some ideas about how to handle that? I'm available to contribute in the next days/weeks :)
Description
Steps to reproduce the issue:
return new JsonResponse(['key' => $request->get('key')]);
# We don't set any Accept nor Content-Type header
curl -d '{"key": "value"} http://domain.tld/path
Describe the results you received:
HTTP/1.1 200 OK
{"key": null}
Describe the results you expected:
HTTP/1.1 406 Not Acceptable
Note: Here we consider that we implement HTTP content negociation the right way so the client must provide a Content-Type header.
From where to start
The actual part of JsonBodyListener incrimined code is:
Other source(s) to watch for inspiration
FOSRestBundle FormatListener.php#L58-L75:
$format = $request->getRequestFormat(null);
if (null === $format) {
$accept = $this->formatNegotiator->getBest('');
if (null !== $accept && 0.0 < $accept->getQuality()) {
$format = $request->getFormat($accept->getValue());
if (null !== $format) {
$request->attributes->set('media_type', $accept->getValue());
}
}
}
if (null === $format) {
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
throw new NotAcceptableHttpException('No matching accepted Response format could be determined');
}
return;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.