Last active
February 5, 2019 19:37
-
-
Save jjn1056/7d981a205d3b183ccb88bdbbd8ad3e40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyApp; | |
use Catalyst 'OpenAPI'; | |
__PACKAGE__->config( | |
'Plugin::OpenAPI' => { | |
# global settings; | |
}, | |
); | |
package MyApp::Controller::User; | |
use MyApp::Controller; | |
sub users | |
:openAPI({ | |
summary: 'Returns worlds by name.', | |
operationId: 'getWorlds', | |
parameters: [ | |
{ | |
in: 'query', | |
name: 'worldName', | |
required: true, | |
type: 'string' | |
} | |
], | |
responses: { | |
200: { | |
description: 'A list of worlds that match the requested name.', | |
schema: { | |
type: 'array', | |
items: { | |
$ref: '#/definitions/World' | |
} | |
} | |
}, | |
default: { | |
description: 'An error occurred', | |
schema: { | |
additionalProperties: true | |
} | |
} | |
} | |
}) ($self, $c) { | |
## Stuff to handle the endpoint | |
} | |
sub users_200 :OpenAPI { ... } | |
sub users_default :OpenAPI { ... } | |
__PACKAGE__->meta->make_immutable(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.npmjs.com/package/express-openapi
https://docs.nestjs.com/recipes/swagger