Skip to content
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

how can specify format for parameters? #732

Closed
ghanbari opened this issue Oct 19, 2015 · 5 comments
Closed

how can specify format for parameters? #732

ghanbari opened this issue Oct 19, 2015 · 5 comments
Labels

Comments

@ghanbari
Copy link

I use input property of @ApiDoc annotation for specifieng of parameters of my api that are form's fields.

* @ApiDoc(
 *      section="User",
 *      resource=true,
 *      input={
 *          "class"="Nik\UserBundle\Form\UserType",
 *      },
 *     ....

data_class of form is a entity that have constraint validation for properties.

I expect that nelmio api doc specify parameter format as validation constraints of entity, but format are empty.

stack overflow

format is empty

How can i specify parameter formats in nelmio ApiDocBundle?

@ghanbari ghanbari changed the title who can specify format for parameters? how can specify format for parameters? Oct 20, 2015
@BenjaminPaap
Copy link
Contributor

With #739 this is now possible. Just override your form parameters with another parameter definition like this:

/**
 * @ApiDoc(
 *     input = {
 *         "class" = "AppBundle\Form\UserForm"
 *     },
 *     parameters = {
 *         { "name" = "firstname", "dataType" = "string", "format" = "My special format" }
 *     }
 * )
 */

@ghanbari
Copy link
Author

@BenjaminPaap @willdurand
what is benefit of use of input class?, if i force define all parameters manually?

@BenjaminPaap
Copy link
Contributor

When using an input class your parameters instantly change when you change the underlying form class.

@ghanbari
Copy link
Author

@BenjaminPaap
yes, it is usefull, but i must always either redefine parameters in @Apidoc or write a another document for UI developer that specify formats for fields.

@ghanbari
Copy link
Author

@willdurand @BenjaminPaap

please see this answer, why validationParser can detect format from FormType properties, but can not guess they from validation annotations that define on entity properties?

sry, i can not speak english good

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

No branches or pull requests

3 participants