# Define the version of the OpenAPI spec to use. Version 2.0 still uses # swagger as the key swagger: "2.0" # general information about the API info: version: "1.0.0" title: "MetaCPAN API" # common path shared throughout the API basePath: "/v1"
1 2 3 4 5 6 7 8 9 10 11 12
paths: # The path to the endpoint /search/web: # The HTTP method that the endpoint accepts get: # A unique identifier for the method operationId: search_web # This attribute points to the name of the class in the appliction # and the method to call separated by `#` x-mojo-to: Search#web # A description of the API Endpoint summary: Perform API search in the same fashion as the Web UI
# The parameters that the HTTP method accepts parameters: # The name of the parameter - name: q # The location to parse the parameter from in: query # Document what the parameter is. This example uses the YAML HEREDOC # syntax to make the description easier to read and write. description: | The query search term. If the search term contains a term with the tags `dist:` or `module:` results will be in expanded form, otherwise collapsed form.
See also `collapsed` # The type of the value that the API accepts type: string # Define the attribute as required required: true # The rest of the parameters that the API accepts - name: from in: query description: The offset to use in the result set type: integer # If the API applies a default to an attribute if it isn't specified. # Let the us know what it is. default: 0 - name: size in: query description: Number of results per page type: integer default: 20 - name: collapsed in: query description: | Force a collapsed even when searching for a particular distribution or module name. type: boolean
responses: # HTTP 200 response 200: description: Search response # The schema defines what the result will look like schema: type: object properties: total: type: integer took: type: number collapsed: type: boolean results: title: Results type: array items: # While items can be further broken into properties per item, # type `object` is a catch all type: object