Coder Social home page Coder Social logo

symfony-json-rest-api's People

Contributors

shouze avatar tyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

tyx

symfony-json-rest-api's Issues

Improve onboarding

We should allow people to use this stuff with a better DX.

  • Bundle ?
  • Flex ?

Copy/Paste is just a problem if we add/modify stuff

Handle Swagger Schema Objects

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 :)

Improve readme

  • We should illustrate with better example each features.
  • We should compare to api-platform to get why this lib exists

Make possible to be strict about format in JsonBodyListener

Description

Steps to reproduce the issue:

  1. Have a Symfony controller action that return this kind of response:
return new JsonResponse(['key' => $request->get('key')]);
  1. then request this action like that:
# 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:

https://github.com/rezzza/symfony-json-rest-api/blob/67639f9383eb4637f6ea56eed136af5373282428/src/JsonBodyListener.php#L34-L40

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;
            }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.