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

Code generation based on service descriptions #17

Closed
mtdowling opened this issue Feb 2, 2012 · 2 comments
Closed

Code generation based on service descriptions #17

mtdowling opened this issue Feb 2, 2012 · 2 comments

Comments

@mtdowling
Copy link
Member

Investigate the possibility of a command line tool that would read service descriptions and generate snippets of code that could be added to a client. For example:

<command name="get_comment" method="GET" path="/comments/{{id}}">
   <doc>Get a comment by ID</doc>
   <param name="id" type="string" required="true" location="path" doc="Comment ID" />
</command>

Would be translated to:

<?php

/**
 * Get a comment by ID 
 *
 * @param string $id Comment ID
 *
 * @return Response|DynamicCommand
 */
public function getComment($id)
{
   $command = $this->getCommand('get_comment', array(
        'id' => $id
    ));

    return $this->getConfig('client.sync') ? $this->execute($command) : $command;
}

The above code could then be added to a client class to make it easier to use the web service. Would be nice to be able to specify whether command parameters are expanded into separate arguments or if an array should be used as an argument for commands with many parameters.

@mtdowling
Copy link
Member Author

I think this would fit more nicely in a guzzle-cli package that would be able to build a client template, generate code as mentioned above, and perform any other CLI actions Guzzle might need in the future.

@mtdowling
Copy link
Member Author

I am not inclined to do this anymore. Closing for now.

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

No branches or pull requests

1 participant