# swaggerhub-maven-plugin
**Repository Path**: mirrors_SmartBear/swaggerhub-maven-plugin
## Basic Information
- **Project Name**: swaggerhub-maven-plugin
- **Description**: A simple maven plugin to access SwaggerHub hosting of OpenAPI/Swagger from a maven build process.
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: develop
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-09-25
- **Last Updated**: 2026-09-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[](https://travis-ci.org/swagger-api/swaggerhub-maven-plugin)
[](https://maven-badges.herokuapp.com/maven-central/io.swagger/swaggerhub-maven-plugin)
# swaggerhub-maven-plugin
A simple maven plugin to access [SwaggerHub](https:\\swaggerhub.com) hosting of [OpenAPI/Swagger](https://swagger.io/specification/) definitions with a maven build process, using the [SwaggerHub API](https://app.swaggerhub.com/apis/swagger-hub/registry-api).
## Features
* Download/upload API definitions from/to SwaggerHub.
* Supports `json` and `yaml` format for API definitions.
* Authenticate with API key for restricted operations (e.g downloading a private API definition).
* Connects to SwaggerHub cloud by default or local SwaggerHub instance through optional configuration.
The pattern of usage is likely to depend on whether a [code first or design first](https://swaggerhub.com/blog/api-design/design-first-or-code-first-api-development/) approach is followed.
## Example use cases
### Code First
1. Code API implementation.
2. Automatically generate API definition from implementation, e.g. via [swagger-core](https://github.com/swagger-api/swagger-core) [annotations](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations) and [swagger maven plugin](https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-maven-plugin). See also [swagger-core wiki](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Getting-started)
3. Upload generated API definition to SwaggerHub with swaggerhub-maven-plugin.
### Design First
1. Write API definition (e.g. in Swagger Editor or SwaggerHub).
2. Download API definition with swaggerhub-maven-plugin.
3. Pass API definition to another Swagger tool e.g.
- [swagger-codegen-maven-plugin](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen-maven-plugin) to generate API client and resource classes.
- [swagger-inflector](https://github.com/swagger-api/swagger-inflector) to automatically wire up the API definition to the implementation and provide out-of-the-box mocking.
## Goals
### download
#### Example Usage
* Download a public API definition in json format from SwaggerHub automatically as part of the default maven build lifecycle and save to a local file.
```xml
io.swagger
swaggerhub-maven-plugin
1.0.2
generate-resources
download
PetStoreAPI
jsfrench
1.0.0
target/petStoreAPI.json
```
#### Parameters
Parameter | Description | Required | Default
--------- | ----------- | --------- | -------
**`api`** | API name | true | -
**`owner`** | API owner | true | -
**`version`** | API version | true | -
**`outputFile`** | API definition is written to this file | true | -
**`token`** | SwaggerHub API key, required to access private definitions | false | -
**`format`** | API definition format, `json` or `yaml` | false | `json`
**`host`** | URL of SwaggerHub API | false | `api.swaggerhub.com`
**`protocol`** | Protocol for SwaggerHub API,`http` or `https` | false | `https`
**`port`** | Port to access SwaggerHub API| false | `443`
***
### upload
#### Example Usage
* Upload an API definition in json format as a public API in SwaggerHub.
```xml
io.swagger
swaggerhub-maven-plugin
1.0.2
deploy
upload
PetStoreAPI
jsfrench
1.0.1-SNAPSHOT
target/petStoreAPI.json
${SWAGGERHUB_APIKEY}
```
#### Example Usage together with `swagger-maven-plugin` (code first)
```xml
io.swagger.core.v3
swagger-maven-plugin
2.0.5
petStoreAPI
${project.build.directory}
JSON
test.petstore
TRUE
compile
resolve
io.swagger
swaggerhub-maven-plugin
1.0.2
deploy
upload
PetStoreAPI
jsfrench
1.0.1-SNAPSHOT
target/petStoreAPI.json
${SWAGGERHUB_APIKEY}
```
#### Parameters
Parameter | Description | Required | Default
--------- | ----------- | --------- | -------
**`api`** | API name | true | -
**`owner`** | API owner | true | -
**`version`** | API version | true | -
**`inputFile`** | Local file containing the API definition in json or yaml format | true | -
**`token`** | SwaggerHub API key | true | -
**`format`** | API definition format, `json` or `yaml` | false | `json`
**`isPrivate`** | Defines whether the API should be private on SwaggerHub (using `true` requires a paid plan) | false | `false`
**`host`** | URL of SwaggerHub API | false | `api.swaggerhub.com`
**`protocol`** | Protocol for SwaggerHub API,`http` or `https` | false | `https`
**`port`** | Port to access SwaggerHub API| false | `443`