-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[jgitflow]merging 'release/1.0.2' into 'master'
- Loading branch information
Showing
14 changed files
with
151 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,112 @@ | ||
# swaggerhub-maven-plugin | ||
A maven plugin to download API definitions from and publish to SwaggerHub. | ||
[![Build Status](https://travis-ci.org/swagger-api/swaggerhub-maven-plugin.svg)](https://travis-ci.org/swagger-api/swaggerhub-maven-plugin) | ||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swaggerhub-maven-plugin/badge.svg?style=plastic)](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/) from a maven build process, primarily to integrate with other OpenAPI/Swagger maven tooling. | ||
|
||
## 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 annotations from [swagger-core](https://github.com/swagger-api/swagger-core). | ||
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 | ||
<plugin> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swaggerhub-maven-plugin</artifactId> | ||
<version>1.0.1</version> | ||
<executions> | ||
<execution> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>download</goal> | ||
</goals> | ||
<configuration> | ||
<api>PetStoreAPI</api> | ||
<owner>jsfrench</owner> | ||
<version>1.0.0</version> | ||
<outputFile>target/petStoreAPI.json</outputFile> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
``` | ||
|
||
#### Parameters | ||
* **api**: API name. | ||
* **owner**": API owner. | ||
* **version**: API version. | ||
* **token**: SwaggerHub API key. | ||
* **outputFile**: Swagger definition downloaded from SwaggerHub is written to this file. | ||
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 | ||
<plugin> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swaggerhub-maven-plugin</artifactId> | ||
<version>1.0.1</version> | ||
<executions> | ||
<execution> | ||
<phase>deploy</phase> | ||
<goals> | ||
<goal>upload</goal> | ||
</goals> | ||
<configuration> | ||
<api>PetStoreAPI</api> | ||
<owner>jsfrench</owner> | ||
<version>1.0.1-SNAPSHOT</version> | ||
<inputFile>target/petStoreAPI.json</inputFile> | ||
<token>${SWAGGERHUB_APIKEY}</token> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
``` | ||
#### Parameters | ||
* **api**: API name. | ||
* **owner**": API owner. | ||
* **version**: API version. | ||
* **token**: SwaggerHub API key. | ||
* **inputFile**: Path to file containing Swagger definition to upload to SwaggerHub. | ||
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` | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.github.jsfrench</groupId> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swaggerhub-maven-plugin</artifactId> | ||
<version>1.0.1</version> | ||
<version>1.0.2</version> | ||
<packaging>maven-plugin</packaging> | ||
<name>SwaggerHub Maven Plugin</name> | ||
<description>A maven plugin for downloading and uploading Swagger/OAS definitions from/to SwaggerHub as | ||
part of a build process. | ||
</description> | ||
<url>https://github.com/jsfrench/swaggerhub-maven-plugin</url> | ||
<url>https://github.com/swagger-api/swaggerhub-maven-plugin</url> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com:jsfrench/swaggerhub-maven-plugin.git</connection> | ||
<developerConnection>scm:git:ssh://github.com:jsfrench/swaggerhub-maven-plugin.git</developerConnection> | ||
<url>https://github.com/jsfrench/swaggerhub-maven-plugin/tree/master</url> | ||
<connection>scm:git:git://github.com:swagger-api/swaggerhub-maven-plugin.git</connection> | ||
<developerConnection>scm:git:ssh://github.com:swagger-api/swaggerhub-maven-plugin.git</developerConnection> | ||
<url>https://github.com/swagger-api/swaggerhub-maven-plugin/tree/master</url> | ||
</scm> | ||
|
||
<licenses> | ||
|
@@ -26,10 +26,14 @@ | |
|
||
<developers> | ||
<developer> | ||
<id>jsfrench</id> | ||
<name>John French</name> | ||
<email>[email protected]</email> | ||
<organization>jsfrench</organization> | ||
<organizationUrl>https://github.com/jsfrench</organizationUrl> | ||
</developer> | ||
<developer> | ||
<id>webron</id> | ||
<name>Ron Ratovsky</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
|
@@ -112,7 +116,7 @@ | |
<pushFeatures>true</pushFeatures> | ||
<pushReleases>true</pushReleases> | ||
<pushHotfixes>true</pushHotfixes> | ||
<noDeploy>false</noDeploy> | ||
<noDeploy>true</noDeploy> | ||
<scmCommentPrefix>[jgitflow]</scmCommentPrefix> | ||
<username>${git.user}</username> | ||
<password>${git.password}</password> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...french/swaggerhub/SwaggerHubDownload.java → ...swaggerhub/plugin/SwaggerHubDownload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...waggerhub/BetterAbstractMojoTestCase.java → ...ub/plugin/BetterAbstractMojoTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ch/swaggerhub/SwaggerHubDownloadTest.java → ...gerhub/plugin/SwaggerHubDownloadTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.