{"id":22574445,"url":"https://github.com/funkeyfreak/api-spec-cleanup","last_synced_at":"2025-03-28T15:24:14.442Z","repository":{"id":37904882,"uuid":"444255885","full_name":"funkeyfreak/api-spec-cleanup","owner":"funkeyfreak","description":" Cleans-Up an Open API 3 Spec File! ","archived":false,"fork":false,"pushed_at":"2023-03-07T16:04:17.000Z","size":641,"stargazers_count":0,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T21:38:32.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/funkeyfreak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-04T02:03:41.000Z","updated_at":"2022-01-04T02:17:08.000Z","dependencies_parsed_at":"2025-02-02T15:40:20.754Z","dependency_job_id":null,"html_url":"https://github.com/funkeyfreak/api-spec-cleanup","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"5195f36c950c77f9a9064bc1d97c3bca479ff15e"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":"actions/typescript-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkeyfreak%2Fapi-spec-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkeyfreak%2Fapi-spec-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkeyfreak%2Fapi-spec-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkeyfreak%2Fapi-spec-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funkeyfreak","download_url":"https://codeload.github.com/funkeyfreak/api-spec-cleanup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246050837,"owners_count":20715722,"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":[],"created_at":"2024-12-08T03:06:13.795Z","updated_at":"2025-03-28T15:24:14.405Z","avatar_url":"https://github.com/funkeyfreak.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API Document Cleanup Action\nThe purpose of this action is to perform a cleanup of an Open API Document so that it will properly generate a Typescript client.\n\n## Functionality\n**Converts boolean enums to booleans in operation parameters.**\n\nConverts parameters that have  `enum: ['false', 'true']` (or reverse) to `type: boolean` and removes the enum property.\n\n**Moves request body schemas that are under a body property up one level to the schema property.**\n\nChanges `{ schema: { body: { title } } }` to `{ schema: { title } }`\n\n**When the required property is empty, it is removed.**\n\nRemoves instances of `{ required: [] }` in request body schemas. \n\n**The schemas listed in path and query params (under the properties params and query) are merged into schemas of the same name in the parameters property.**\n\nHere, properties `params and query` from `paths[path][method].requestBody.content[media].schema` are merged into the `paths[path][method].parameters` property, preferring the properties that already exist in the `parameters` property. These parameter values are preferred because they are more likely to be a better a representation of the types expected from an API client. \n\nExample input\n```js\n// params object in paths[path][method].requestBody.content[media].schema\n{ \n    params: {\n        properties: {\n            resourceId: { type: 'string', minLength: 1 }\n        }\n    }\n}\n// paths[path][method].parameters\n[{\n    name: 'resourceId',\n    in: 'path',\n    schema: {\n        type: 'number'\n    }\n}]\n```\nExample result \n```js\n// paths[path][method].parameters\n[{\n    name: 'resourceId',\n    in: 'path',\n    schema: {\n        type: 'number',\n        minLength: 1\n    }\n}]\n```\n\n**Path and query params (under the properties params and query) are deleted out of requestBody properties**\n\nAfter the `params` and `query` properties in `paths[path][method].requestBody.content[media].schema` are merged into ```paths[path][method].parameters``` they are deleted from the requestBody.\n\n**Creates parameters if they are missing**\n\nIf parameters exist in `params` or `query` properties in `paths[path][method].requestBody.content[media].schema`, but do not exist in `paths[path][method].parameters`, they are created in `paths[path][method].parameters`.\n\n\n**Operation ids are converted to camelCase.**\n\nTo create operationIds that can easily be used as function names, they are converted to camelCase. For example `My Operation - Name` becomes `myOperationName`.\n\n**Operation ids are made unique.**\n\nThis is accomplished by appending a number to duplicate ids.\n\n**Removes any YAML anchors in YAML files**\n\nSome libraries generate YAML anchors automatically for any duplicate objects. These are removed to allow for proper API generation.\n\n**Converts multi-line descriptions into single lines for YAML files**\n\nThis is accomplished by removing the default line limit in `js-yaml`. If necessary, this can be made configurable at a later date.\n\n## Example Usage\n```yaml\n# .github/workflows/cleanup-action.yml\nname: My Cleanup Action\n\nenv: \n  FILE_PATH: lib/openapi.yaml\n\njobs:\n  validate_openapi_301:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n\n      - name: Check if OpenAPI Schema Exists\n        id: check_openapi_file\n        uses: andstor/file-existence-action@v1\n        with:\n          files: \"${{ env.FILE_PATH }}\"\n      \n      - name: Clean Up OpenAPI Doc\n        uses: funkeyfreak/api-spec-cleanup@v1\n        with:\n          file: ${{ env.FILE_PATH }} \n\n      - name: Commit newly generated schema\n        uses: stefanzweifel/git-auto-commit-action@v4\n        with:\n          commit_message: 'github actions: openapi schema modified'\n          file_pattern: ${{ env.FILE_PATH }}\n```\n\n## Dev\nNote: this process may change if breaking changes are introduced or semantic versioning becomes necessary. **Currently, all changes are pushed to v1.**\n1. Make changes to `main`\n2. Run `npm run package`\n3. Commit\n4. Run `npm run release`\n5. Push\n\n## Test\n```\nnpm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunkeyfreak%2Fapi-spec-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunkeyfreak%2Fapi-spec-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunkeyfreak%2Fapi-spec-cleanup/lists"}