A word of warning: this repo is probably rendered obsolete by the release of PSSwagger.
Generate PowerShell module from OpenAPI spec using Swagger Codegen.
Swagger Codegen 2.2.3 aims to have PowerShell module generator. Until it's released, you can build latest version of Swagger Codegen yourself, which already has beta-quality PowerShell support and use it to generate PowerShell module.
- Accompanying post: Building PowerShell modules with Swagger Codegen
- Discussion: [PowerShell] Add PowerShell API client generator
- Pull Request: PowerShell module
This repository contains set of scripts that will:
- Install Chocolatey
- Install JDK and Maven
- Clone Swagger Codegen repo: https://github.com/swagger-api/swagger-codegen
You need to have Git installed. Chocolatey can do this for you:choco install git -params "/GitAndUnixToolsOnPath"
- Build Swagger Codegen from source using Maven
- Generate PowerShell module using either API name to get OpenAPI spec from APIs.guru or custom
swagger.json
/swagger.yml
file.
You can view full list of APIs.guru APIs here: https://github.com/APIs-guru/openapi-directory
Generated module will be available in the ApiName\PowerShell\src\IO.Swagger
directory.
To import it use: Import-Module -name .\ApiName\PowerShell\src\IO.Swagger
Build XKCD module
If run without arguments, Build.ps1
script will install all prerequisites, build Swagger Codegen and generate XKCD module using this spec: https://github.com/APIs-guru/openapi-directory/tree/master/APIs/xkcd.com/1.0.0
- Run PowerShell/PowerShell ISE as admin
- Run
Build.ps1
script
If you already run Build.ps1
script and have all prerequisites, you can build custom PowerShell modules.
Build instagram.com
module by API name
.\Build.ps1 -ApiName instagram.com
Build instagram.com
module from file
.\Build.ps1 -ApiName instagram.com -InFile .\path\to\spec\swagger.yml
To pull latest changes and rebuild Swagger Codegen, add UpdateCodegen
switch.
.\Build.ps1 -UpdateCodegen