Skip to content

Swagger does not reference correct schema when using embedded resource #1657

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

Closed
Toflar opened this issue Jan 17, 2018 · 1 comment
Closed

Comments

@Toflar
Copy link
Contributor

Toflar commented Jan 17, 2018

Sorry guys, I tried to provide a PR directly but the DocumentationNormalizer is a bit too complex at the moment. I don't quite see how all these names go together so here's the issue. If you can guide me I can help with a PR.

/**
 * @ApiResource(
 *     attributes={
 *         "normalization_context"={"groups"={"Quickcheck_GET"}},
 *         "denormalization_context"={"groups"={"Quickcheck_POST"}
 *    }
 * })
 */
class Quickcheck
{
    /**
     * @var QuickcheckAnswer[]
     *
     * @ORM\OneToMany(targetEntity="QuickcheckAnswer", mappedBy="quickcheck", cascade={"all"})
     * @ApiSubresource
     * @Groups({"Quickcheck_GET", "Quickcheck_POST"})
     */
    private $quickcheckAnswers;
}
/**
 * @ApiResource(
 *     attributes={
 *         "normalization_context"={"groups"={"QuickcheckAnswer_GET"}},
 *         "denormalization_context"={"groups"={"QuickcheckAnswer_POST", "Quickcheck_POST"}}
 *    }
 * )
 */
class QuickcheckAnswer {}

So I can POST to /quickcheck like so just fine:

    {
      "quickcheckAnswers":[
        {
          "key":"foo",
          "value":"whatever"
        },
        {
          "key":"foo2",
          "value":"whatever2"
        }
      ]
    }
    """

it all gets deserialized and updated correctly, awesome! But swagger shows me this:

bildschirmfoto 2018-01-17 um 17 59 47
bildschirmfoto 2018-01-17 um 17 59 57
bildschirmfoto 2018-01-17 um 18 00 01

I'd expect it to embed the schema instead.
I don't quite understand why there's a model for each combination of all groups because @Groups({"Quickcheck_GET", "Quickcheck_POST"}) means either Quickcheck_GET or Quickcheck_POST, imho.

Thanks for the help!

@soyuka
Copy link
Member

soyuka commented Apr 7, 2019

Closing in favor of #2706

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants