{"id":13707103,"url":"https://github.com/minitauros/swagen","last_synced_at":"2026-02-11T00:04:35.147Z","repository":{"id":144202050,"uuid":"216055664","full_name":"minitauros/swagen","owner":"minitauros","description":"Generate Swagger/OpenAPI YAML from a MySQL database schema","archived":false,"fork":false,"pushed_at":"2023-11-28T10:43:47.000Z","size":37,"stargazers_count":11,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-13T15:49:30.694Z","etag":null,"topics":["openapi-codegen","openapi-generator","swagger","swagger-codegen","swagger-generator"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minitauros.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-18T15:34:30.000Z","updated_at":"2023-11-30T15:54:59.000Z","dependencies_parsed_at":"2024-11-13T15:44:11.870Z","dependency_job_id":null,"html_url":"https://github.com/minitauros/swagen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minitauros%2Fswagen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minitauros%2Fswagen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minitauros%2Fswagen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minitauros%2Fswagen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minitauros","download_url":"https://codeload.github.com/minitauros/swagen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252593336,"owners_count":21773444,"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":["openapi-codegen","openapi-generator","swagger","swagger-codegen","swagger-generator"],"created_at":"2024-08-02T22:01:19.350Z","updated_at":"2026-02-11T00:04:35.127Z","avatar_url":"https://github.com/minitauros.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Swagen\nSwagen reads your MySQL database and generates Swagger/OpenAPI YAML from table meta data. This results in a boilerplate swaggerfile (YML) that should probably be edited to completely suit your needs. Use [go-swagger](https://github.com/go-swagger/go-swagger) or [swagger-codegen](https://github.com/swagger-api/swagger-codegen) to generate the API boilerplate Go code.\n\n## Swagger version\nSwagen generates Swagger/OpenAPI 2.0 configuration.\n\n## Installation\nSwagen can be acquired and installed by running\n\n```\ngo get -v -u github.com/minitauros/swagen\n```\n\n## How to build\nOr, alternatively, the binary can be manually built:\n\n```\ngo build -o ~/bin/swagen main.go\n```\n\n## Usage\n\n### Creating a config file\nYou will need to create a small config file that Swagen uses to generate YML. For example:\n\n```\ndb:\n  dsn: root:@tcp(127.0.0.1:3306)/db_name\n\nservice:\n  name: MyService\n  host: 127.0.0.1:1234\n\nresources:\n  table_name:\n    # The written name of the resource, e.g. \"product\". Will be used in summaries.\n    title: written name of resource\n    definition:\n      # This is how the resource will be named in the definitions list.\n      name: ResourceDefinition\n  # Continue listing all the tables you want to generate Swagger YAML for.\n```\n\n### Running Swagen\nSwagger YML can then be generated using the following command:\n\n```\nswagen -conf=conf.yml \u003e swagger.yml\n```\n\n### Example\nProducts table:\n\n```sql\nCREATE TABLE products (\n    id INT NOT NULL AUTO_INCREMENT,\n    name VARCHAR(255) NOT NULL,\n    price INT NOT NULL,\n    PRIMARY KEY (id)\n); \n```\n\nConfig:\n\n```\ndb:\n  dsn: root:@tcp(0.0.0.0:3306)/products?parseTime=true\n\nservice:\n  name: TestService\n  host: 1.1.1.1:1234\n\nresources:\n  products:\n    title: product\n    definition:\n      name: Product\n```\n\nResult:\n\n```\nswagger: '2.0'\ninfo:\n  title: TestService\n  version: 1.0.0\nhost: 1.1.1.1:1234\nbasePath: /v1\nschemes:\n  - http\nconsumes:\n  - application/json\nproduces:\n  - application/json\npaths:\n  /products:\n    get:\n      summary: Returns the product resources with the given IDs\n      parameters:\n        - in: query\n          name: ids\n          type: array\n          items:\n            type: integer\n      responses:\n        200:\n          description: List of product resources\n          schema:\n            type: array\n            items:\n              $ref: '#/definitions/Product'\n        500:\n          description: Internal server error\n    post:\n      summary: Creates a product\n      parameters:\n        - name: resource\n          in: body\n          required: true\n          schema:\n            $ref: '#/definitions/Product'\n      responses:\n        200:\n          description: Success\n        400:\n          description: Bad request\n          schema:\n            $ref: '#/definitions/Error'\n        500:\n          description: Internal server error\n  /products/{id}:\n    get:\n      summary: Returns the product with the given ID\n      parameters:\n        - in: path\n          name: id\n          type: integer\n          required: true\n      responses:\n        200:\n          description: Single product\n          schema:\n            $ref: '#/definitions/Product'\n        404:\n          description: Not found\n        500:\n          description: Internal server error\n    patch:\n      summary: Patches the product with the given ID\n      parameters:\n        - name: id\n          in: path\n          type: integer\n          required: true\n        - name: patch\n          in: body\n          required: true\n          schema:\n            $ref: '#/definitions/Patch'\n      responses:\n        200:\n          description: Success\n        400:\n          description: Bad request\n          schema:\n            $ref: '#/definitions/Error'\n        404:\n          description: Not found\n        500:\n          description: Internal server error\n    put:\n      summary: Replaces the product with the given ID\n      parameters:\n        - name: id\n          in: path\n          type: integer\n          required: true\n        - name: resource\n          in: body\n          required: true\n          schema:\n            $ref: '#/definitions/Product'\n      responses:\n        200:\n          description: Success\n        400:\n          description: Bad request\n          schema:\n            $ref: '#/definitions/Error'\n        404:\n          description: Not found\n        500:\n          description: Internal server error\n    delete:\n      summary: Deletes the product with the given ID\n      parameters:\n        - name: id\n          in: path\n          type: integer\n          required: true\n      responses:\n        200:\n          description: Success\n        404:\n          description: Not found\n        500:\n          description: Internal server error\ndefinitions:\n  Product:\n    properties:\n      id:\n        type: integer\n      name:\n        type: string\n      price:\n        type: integer\n  Patch:\n    type: array\n    description: Patch instructions\n    items:\n      type: object\n      required:\n        - op\n        - path\n        - value\n      properties:\n        op:\n          type: string\n          description: Operation\n        path:\n          type: string\n          description: Path to field to operate on\n        value:\n          $ref: '#/definitions/AnyValue'\n  AnyValue:\n    description: Any type of value\n  Error:\n    type: object\n    properties:\n      message:\n        type: string\n\n```\n\n## Tests\nThis package does not contain tests. Since it would be foolish to run this directly in any production environment, I will assume that every time this tool might be used, the person using it will check and modify the output (as the tool attow only generates boilerplate YML). On top of that, if invalid YML is generated, other tools (like swagger-codegen) will break, also spotting any defects.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminitauros%2Fswagen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminitauros%2Fswagen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminitauros%2Fswagen/lists"}