Snapshots are available from the Sonatype Nexus Snapshots repository. To use a snapshot version, add the following to the <repositories> section of your pom.xml:
SwaggerHub API key, required to access private definitions
no
-
definitionType
Definition type, API or domain
no
API
format
File format to download, json or yaml
no
json
host
SwaggerHub hostname. Use api.swaggerhub.com for SwaggerHub SaaS.
no
api.swaggerhub.com
protocol
SwaggerHub server protocol, http or https
no
https
port
SwaggerHub server port, typically 80 for http and 443 for https
no
443
basepath
Base path prefix for SwaggerHub Registry API calls. Leave blank for SwaggerHub SaaS, use v1 for SwaggerHub On-Premise.
no
-
upload
This goal creates or updates one or more API or domain definitions on SwaggerHub. All definitions are saved in the owner account (organization or user), and the token owner must have permissions to create and update definitions in this account.
Additionally, there is the option of provisioning a SwaggerHub SCM integration which will allow changes made in SwaggerHub to be pushed back to source control.
There are two uploadType modes:
inputFile - Upload a single API or domain definition.
directory - Upload one or more definitions from the specified definitionDirectory, optionally filtered by a regular expression. All definitions must be of the same type - either all APIs or all domains.
Parameters
Common parameters:
Parameter
Description
Required?
Default
uploadType
Possible values: inputFile - upload a single API or domain; directory - upload multiple definitions stored in a directory
yes
-
owner
The account name (case-sensitive) to upload the definitions to
yes
-
token
SwaggerHub API key. The API key owner must have permissions to create and update definitions in the owner account
yes
-
definitionType
Definition type, API or domain
no
API
isPrivate
Specifies whether the uploaded definitions will be made public (false) or private (true)
no
false
skipFailures
Specifies whether a build should fail when errors are encountered
no
false
host
SwaggerHub hostname. Use api.swaggerhub.com for SwaggerHub SaaS.
no
api.swaggerhub.com
protocol
SwaggerHub server protocol, http or https
no
https
port
SwaggerHub server port, typically 80 for http and 443 for https
no
443
basepath
Base path prefix for SwaggerHub Registry API calls. Leave blank for SwaggerHub SaaS, use v1 for SwaggerHub On-Premise.
no
-
Additional parameters for uploadType=inputFile:
Parameter
Description
Required?
Default
api
The name of the API or domain to create or update (case-sensitive)
yes
-
version
Version to create or update (case-sensitive). If this version already exists, it must not be published.
yes
-
inputFile
Local file containing the API or domain definition in the JSON or YAML format
yes
-
format
Definition format, json or yaml
no
json
Additional parameters for uploadType=directory:
Parameter
Description
Required?
Default
definitionDirectory
Directory containing the definitions to be uploaded to SwaggerHub. Note that subdirectories are not included in the upload.
yes
-
definitionFileNameRegex
Regular expression that specifies the files to be uploaded. This regex matches against file names without extensions. If not specified, all .json, .yaml and .yml files from the definitionDirectory will be uploaded.
User generated API token to be used for SCM requests
no
GITHUB
-
scmPersonalAccessToken
Similar to the above
no
AZURE_DEVOPS_SERVICES
-
scmUsername
The account-name (case-sensitive) with which to authenticate
no
BITBUCKET
-
scmPassword
The password to be used in conjunction with the above scmUsername
no
BITBUCKET
-
repository
The repository to push SwaggerHub changes to
yes
-
-
repositoryOwner
The SCM account which owns the above repository
no
GITHUB. BITBUCKET
-
scmProject
Team Project which contains the target repository
no
AZURE_DEVOPS_SERVICES
-
scmOrganization
Specific to Azure DevOps Services, the organization with which to synchronize
no
AZURE_DEVOPS_SERVICES
-
scmUrl
Host URL of the SCM
no
AZURE_DEVOPS_SERVER
-
scmHost
Similar to the above
no
GITLAB
-
scmProjectCollection
Project collection which contains the target repositories project
no
AZURE_DEVOPS_SERVER
DefaultCollection
enableScmIntegration
Specifies whether to enable the SCM integration. If enabled, SwaggerHub changes will be pushed automatically on save
no
-
true
branch
The repository branch to push SwaggerHub changes to
no
-
SWAGGERHUB
Multi-upload considerations
When using uploadType=directory, all definitions to be uploaded must be stored in the definitionDirectory (the directory itself, not subdirectories). The definitionType parameter specifies whether the files will be uploaded as APIs (default) or domains.
The plugin only processes files with the following extensions: .yaml, .yml, .json. Files with other extensions are ignored. The files must be valid JSON or YAML files.
By default, the plugin uploads all JSON and YAML files from the specified directory, but you can use definitionFileNameRegex to narrow down the files to be uploaded. The regular expression matches against file names without file extensions. The matching is partial unless the regex contains the ^ (beginning of line) and $ (end of line) anchors. To make the matching case-insensitive, include (?i) at the beginning, or (?iu) for Unicode-aware case-insensitive matching. Examples:
acme matches file names that contain "acme" in lower case.
^acme matches file names that begin with "acme" in lower case.
^(?i)acme matches file names that begin with "acme" in any letter case.
API/domain names and versions are generated by parsing the info section of the definitions. The info section must include non-empty title and version keys.
Names are generated based on the info.title, with characters other than A-Za-z0-9_ replaced with underscores. For example, a definition with title: Sample API will be saved under the name Sample_API on SwaggerHub.
Versions are extracted from the info.version key. If this version already exists in SwaggerHub, it will be updated with the new definition (unless the version is published - in this case the update will be rejected).
If an error occurs while uploading any definition, the build will fail and subsequent definitions will not be uploaded.
SwaggerHub On-Premise supports this method of SCM integration provisioning since v. 1.20.0.
Care should be taken when specifying SCM parameters. Validation does not take place prior to making the request to SwaggerHub and issues can arise due to incorrectly configured integrations
Use only the parameters that are required for the SCM of your choice. For example BITBUCKET relies on scmUsername and scmPassword;
if an scmToken is also included, the Bitbucket integration will attempt to authenticate with the token. This is not possible and will cause integration errors.
BITBUCKET can use app passwords to authenticate. App passwords are substitute passwords for a user account which you can use for scripts and integrating tools to avoid putting your real password into configuration files.
App password permissions required are:
Account : Email, Read
Repositories : Read, Write
Documentation on how to generate an app password can be found here.
AZURE_DEVOPS_SERVICES and AZURE_DEVOPS_SERVER use personal access tokens which will eventually expire. In the event of token expiring, the integration will need to be deleted and recreated (either manually or via the plugin).
See Microsoft documentation here for details on creating a Personal Access Token. Please ensure that the token has at minimum the scope Code (read and write) for the organization you wish to access
A list of AZURE_DEVOPS_SERVICES organizations that you currently have access to can be found here. Also listed are the projects for each organization.
Enter just the organization, without ‘dev.azure.com’ at the beginning or ‘.visualstudio.com’ at the end. For example, if your organization is ‘dev.azure.com/example-user’ or 'example-user.visualstudio.com’, enter just 'example-user’.
Due to GITLAB's nested group support, when specifying repository it is required to specify the full path. For example <repository>root-level-group/sub-level-group/repo</repository>
请发表评论