Coder Social home page Coder Social logo

Comments (5)

pylebecq avatar pylebecq commented on September 23, 2024

I can confirm that. There is also another thing : if an option is required but does not have a default value.

from nelmioapidocbundle.

willdurand avatar willdurand commented on September 23, 2024

Tagged as "enhancement", feel free to work on it :)

from nelmioapidocbundle.

odoucet avatar odoucet commented on September 23, 2024

Small work on this task : doc is empty because the formType cannot be created. This is because when you use dataTransformers, you have to extend setDefaultOptions() and require an option 'em' as ObjectManager.
NelmioDocType does not pass it at creation, and silently dropped the error (better have an empty doc for this form, than no doc at all).

So this works:

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'My\APIBundle\Entity\User',
            'csrf_protection'   => false,
        ));
    }

And this does not :

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'My\APIBundle\Entity\User',
            'csrf_protection'   => false,
        ))
        ->setRequired(array(
                'em'
        ))
        ->setAllowedTypes(array(
                'em' => 'Doctrine\Common\Persistence\ObjectManager',
            ))
        ;
    }

So to support DataTransformer, I think we need to modify Parser/FormTypeParser.php

from nelmioapidocbundle.

nazar256 avatar nazar256 commented on September 23, 2024

Hi guys, I've faced the same problem. But looking at how ApiDoc bundle works for few minutes I've found a solution for my case! Here it is:

  1. First, define your form as service, it is pretty easy, suppose it is "form_alias_you_defined"
  2. Inject needed services to form (ex. EntityManager)
  3. Use your form name in ApiDoc instead of form class like this:
/**
* ...
* input = "form_alias_you_defined"
*/

Profit!
Also don't forget to read official documentation with usefull tips, like passing method (GET, POST, etc).

from nelmioapidocbundle.

dbu avatar dbu commented on September 23, 2024

version 3 is a complete rewrite. please check if this is still a problem with version 3 and a recent symfony version.

from nelmioapidocbundle.

Related Issues (20)

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.