{"id":15068595,"url":"https://github.com/techship/apollo-openapi","last_synced_at":"2026-01-02T18:06:28.911Z","repository":{"id":57023912,"uuid":"174852118","full_name":"techship/apollo-openapi","owner":"techship","description":"Light OpenAPI parser library in PHP","archived":false,"fork":false,"pushed_at":"2021-08-11T16:09:09.000Z","size":66,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T21:22:04.676Z","etag":null,"topics":["library","openapi","parser","php","php7","swagger"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techship.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-10T16:47:50.000Z","updated_at":"2021-12-23T19:51:38.000Z","dependencies_parsed_at":"2022-08-23T14:21:00.325Z","dependency_job_id":null,"html_url":"https://github.com/techship/apollo-openapi","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techship%2Fapollo-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techship%2Fapollo-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techship%2Fapollo-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techship%2Fapollo-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techship","download_url":"https://codeload.github.com/techship/apollo-openapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847056,"owners_count":20357317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","openapi","parser","php","php7","swagger"],"created_at":"2024-09-25T01:38:27.244Z","updated_at":"2026-01-02T18:06:23.885Z","avatar_url":"https://github.com/techship.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"logo.png\" alt=\"logo\" title=\"apollo-openapi\" width=\"200\" \u003e\n\nLight OpenAPI parser library in PHP based on the [OpenAPI Specification](https://swagger.io/docs/specification/about/) allowing developers to extract easily schema's data.\n\n## How to install?\n\n```\n$ composer require nass59/apollo-openapi\n```\n\n## What can you do with it?\n\n### Get Paths\n\nIn OpenAPI terms, paths are endpoints (resources), such as /users or /reports/summary/, that your API exposes.\n\nAll paths are relative to the API server URL.\n\n```php\n$openAPI = new OpenAPI('config/schemas/', 'apollo.yaml');\n$openAPI-\u003egetPaths();\n/*\n * [\n *   '/articles',\n *   '/articles/{id}',\n *   '/images',\n *   ...\n * ]\n */\n```\n\n### Get Paths with Operations\n\nIn OpenAPI terms, paths are endpoints (resources),  such as /users or /reports/summary/, that your API exposes. \n\nOperations are the HTTP methods used to manipulate these paths, such as GET, POST or DELETE.\n\n```php\n$openAPI = new OpenAPI('config/schemas/', 'apollo.yaml');\n$openAPI-\u003egetPathsWithOperations();\n/*\n * [\n *   '/articles' =\u003e [\n *     'get' =\u003e [...],\n *     'post' =\u003e [...],\n *   ],\n *   '/articles/{id}' =\u003e [\n *     'get' =\u003e [...],\n *   ],\n *   ...\n * ]\n */\n```\n\n### Get Path with Operations\n\nGet a specific path (i.e endpoint) and return its operations.\n\n```php\n$openAPI = new OpenAPI('config/schemas/', 'apollo.yaml');\n$openAPI-\u003egetPathWithOperations('/articles');\n/*\n * [\n *   'get' =\u003e [...],\n *   'post' =\u003e [...],\n * ]\n */\n```\n\n### Get the Request Body\n\nThe request body usually contains the representation of the resource to be created.\n\nOpenAPI 3.0 provides the requestBody keyword to describe request bodies. \n\n\u003e Request bodies are optional by default.\n\n```php\n$openAPI = new OpenAPI('config/schemas/', 'apollo.yaml');\n$operations = $openAPI-\u003egetPathWithOperations('/articles');\n$openAPI-\u003egetRequestBody($operations['post']);\n/*\n * [\n *   '$ref' =\u003e '#/components/requestBodies/ArticleBody',\n * ]\n */\n```\n\n### Get a Definition\n\nOpenAPI 3.0 data types are based on an extended subset JSON Schema Specification Wright Draft 00.\n\nThe data types are described using a Schema object.\n\n```php\n$openAPI = new OpenAPI('config/schemas/', 'apollo.yaml');\n$openAPI-\u003egetDefinition('/articles', 'postArticle');\n/*\n * [\n *   'type' =\u003e 'object',\n *   'required' =\u003e ['name', 'headline'],\n *   'additionalProperties' =\u003e false,\n *   'properties' =\u003e [\n *     'name' =\u003e ['type' =\u003e 'string'],\n *     'headline' =\u003e ['type' =\u003e 'string'],\n *     ...\n *   ]\n * ]\n */\n```\n\n### Example of Schema\n\n```yaml\nopenapi: 3.0.0\n\nservers:\n  - url: 'https://api.apollo.dev:8091/'\n\ninfo:\n  version: \"v1-oas3\"\n  title: Apollo API\n  description: Share images and videos with your friends.\n  termsOfService: terms\n  license:\n    name: MIT\n    url: https://opensource.org/licenses/MIT\n\ntags:\n  - name: article\n    description: Everything about articles\n\npaths:\n  /articles:\n    get:\n      tags:\n        - article\n      operationId: getArticles\n      summary: ''\n      description: Get a list of articles\n      parameters:\n        - name: fields[articles]\n          in: query\n          description: List of fields to display separated by a comma.\n          example: \"name,headline\"\n          required: false\n          schema:\n            type: string\n        - name: sort\n          in: query\n          description: Field use to sort the result.\n          example: \"-name\"\n          required: false\n          schema:\n            type: string\n        - name: page[offset]\n          in: query\n          description: Number of page to skip.\n          required: false\n          schema:\n            type: integer\n            default: 1\n        - name: page[limit]\n          in: query\n          description: The numbers of items to return.\n          required: false\n          schema:\n            type: integer\n            default: 20\n      responses:\n        '200':\n          description: Successful operation\n          content:\n            application/hal+json:\n              schema:\n                $ref: '#/components/schemas/Collection'\n    post:\n      tags:\n        - article\n      operationId: postArticle\n      summary: ''\n      description: Create a new article\n      responses:\n        '201':\n          description: Successful operation\n          content:\n            application/hal+json:\n              schema:\n                $ref: '#/components/schemas/Article'\n        '400':\n          description: Bad request\n      requestBody:\n        $ref: '#/components/requestBodies/ArticleBody'\n\n  /articles/{id}:\n    get:\n      tags:\n        - article\n      operationId: getArticle\n      summary: ''\n      description: Get a specific article\n      parameters:\n        - name: id\n          in: path\n          description: The id of the article\n          required: true\n          schema:\n            type: string\n      responses:\n        '200':\n          description: Successful operation\n        '404':\n          description: Article not found\n    put:\n      tags:\n        - article\n      summary: ''\n      description: Update an existing article\n      operationId: putArticle\n      parameters:\n        - name: id\n          in: path\n          description: The id of the article\n          required: true\n          schema:\n            type: string\n      responses:\n        '200':\n          description: Successful operation\n          content:\n            application/hal+json:\n              schema:\n                $ref: '#/components/schemas/Article'\n        '400':\n          description: Bad request\n        '404':\n          description: Article not found\n      requestBody:\n        $ref: '#/components/requestBodies/ArticleBody'\n    delete:\n      tags:\n        - article\n      summary: ''\n      description: Delete a specific article\n      operationId: deleteArticle\n      parameters:\n        - name: id\n          in: path\n          description: The id of the article\n          required: true\n          schema:\n            type: string\n      responses:\n        '204':\n          description: Article deleted\n        '404':\n          description: Article not found\n          \ncomponents:\n  schemas:\n    ArticleBody:\n      type: object\n      required:\n        - name\n        - headline\n        - article_body\n        - author\n      additionalProperties: false\n      properties:\n        name:\n          type: string\n          example: My first article\n        headline:\n          type: string\n          description: Headline of the article.\n          example: Traveling is great!\n        article_body:\n          type: string\n          description: The actual body of the article.\n          example: Traveling is great because...\n        author:\n          type: string\n          description: The author of this content\n          example: John Doe\n        article_section:\n          type: string\n          example: discovery\n          enum:\n            - 'discovery'\n            - 'travel'\n            - 'update'\n        tags:\n          type: array\n          items:\n            type: string\n            example: 'New York'\n\n    Article:\n      type: object\n      properties:\n        article:\n          $ref: '#/components/schemas/ArticleBody'\n\n    Collection:\n      type: object\n      properties:\n        _links:\n          type: object\n        _embedded:\n          type: object\n          items:\n            type: object\n\n  requestBodies:\n    ArticleBody:\n      content:\n        application/hal+json:\n          schema:\n            $ref: '#/components/schemas/ArticleBody'\n      description: Article object.\n      required: true\n```\n\n## Run tests\n\n```\n$ phpdbg -qrr ./vendor/phpspec/phpspec/bin/phpspec run -f progress\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechship%2Fapollo-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechship%2Fapollo-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechship%2Fapollo-openapi/lists"}