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

include json file in annotations - Blueprint #654

Closed
ClaudioVarandas opened this issue Sep 22, 2015 · 12 comments
Closed

include json file in annotations - Blueprint #654

ClaudioVarandas opened this issue Sep 22, 2015 · 12 comments
Labels
Milestone

Comments

@ClaudioVarandas
Copy link

Hello,

sorry open a issue for this but it really helps, i wanna include a file with a json response in the body. It's possible ?

example:

@response(200, body={"name" : "foo",}) ----> @response(200, body= include(filename))

thx

CV

@jasonlewis
Copy link
Contributor

Hm, that's an interesting one... It's not possible, but it could be interesting.

You want to do this because including a sample response body is too big for this particular response?

@smartfin
Copy link

Is it possible to read the file and then return response with read data?

@marijang
Copy link

marijang commented Nov 9, 2015

+1

@marijang
Copy link

it will be cool to have something like this
@partial(path\filename.md)

So we can separate documentation from controller code
What do you think?

@marsderp
Copy link

+1
Currently encountering reponse data that is too big (+50 lines when exploded) to put into the controller for practical reasons.

External documentation could be preferred at this point.

@jasonlewis
Copy link
Contributor

I'm tempted on this idea guys. Will put it into the 1.0.0 milestone and see how I go when I get back from holidays.

@jasonlewis jasonlewis added this to the v1.0.0 milestone Dec 23, 2015
@realshadow
Copy link

@jasonlewis Hey, did you get anywhere with this feature? I could really use this :)

@jasonlewis
Copy link
Contributor

I've just implemented this on both here and the Blueprint repository.

To use it, you simply provide a string body for either a request or a response, but prefix the string with either json: or file:, then provide a path relative to the base directory.

Example:

/**
 * @Response(200, body="json:docs/response/example")
 */

If you use json: then you don't need to worry about a .json file extension. If your files are not using a .json extension then use the file: prefix and provide the extension.

If the contents of the files is valid JSON it will not be re-encoded.

When using the command there's a new --include-path option which you can use to configure a base path relative to the root directory. So, for example, your docs are stored at {root}/docs, but you don't want to write docs/response/example every time.

So when you call the command you would use --include-path "docs", your annotation would then look like this:

/**
 * @Response(200, body="json:response/example")
 */

Let me know if you'd prefer the --include-path option to not default to being relative to the root directory.

@rajathans
Copy link

rajathans commented Aug 17, 2016

what happened to this feature i cant use --include-path anymore.
Gives me :

[Symfony\Component\Console\Exception\RuntimeException]  
The "--include-path" option does not exist.  

@hskrasek
Copy link
Member

@rajathans Nothing happened to it, the option still exists. Are you possibly on a version that was before this was added?

@rajathans
Copy link

rajathans commented Aug 18, 2016

@hskrasek i'm using "dingo/api": "1.0.x@dev" in my composer.json

@hskrasek
Copy link
Member

@rajathans Trying switching to "dev-master" in your composer file. That should resolve the issue

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

8 participants