-
Notifications
You must be signed in to change notification settings - Fork 931
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
Custom HTTP methods #321
Comments
The swagger spec defines only has the standard verbs for a path Too generate swagger output with custom verbs you'l need to create an annotation that extends from Path and patch Swagger. class CustomPath extends Swagger\Annotations\Path { ... }
class CustomMethod extends Swagger\Annotations\Operation { ... }
Swagger\Annotations\Swagger::$_nested['CustomPath'] = ['paths', 'path'];
/**
* @CustomPath(path="/some/path", @CustomMethod(description="really special"))
*/
function reallySpecial() { ... } This might work, but it's not valid swagger output. |
Thanks for the answer.
Just to explain the reasoning, the exact operation is a clone/copy of an existing resource......using POST for that seems misleading, as POST has it's own clear meaning. Allowing a custom* method of COPY seems to make the API a lot more intuitive:
Oh darn. We're actually also going to be using other tools that consume the Swagger spec JSON....they're unlikely to be happy with custom verbs.
|
Thanks for the explaination, I'd personally would go for |
Yeah, I'll almost certainly do that. I also just realised that the COPY verb actually doesn't have the correct semantics either, as for WEBDAV where it apparently comes from, you have to send an id to copy it to, and COPY is meant to be idempotent. A CLONE method wouldn't be idempotent, and the client wouldn't know the id before the clone...so yeah, give up and use ~~~tables~~~ POST. |
Hi there!
For an API we're building, one of the api end-points we need to expose doesn't fit well within the normal HTTP methods/verbs.
Is it possible to tell swagger-php about non-standard methods so it can generate the appropriate swagger api json for them?
I had a look but it seems that they are hard-coded here, and I can't see a way to plug any other types in.
cheers
Dan
The text was updated successfully, but these errors were encountered: