Skip to content

Commit 15d69ea

Browse files
authored
Merge pull request #2954 from swagger-api/plugins
implements maven and gradle plugins
2 parents bbba4af + 4288f96 commit 15d69ea

File tree

223 files changed

+10928
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+10928
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Swagger-core is the Java implementation of Swagger. Current version supports *JA
1111
Check out the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project.
1212

1313
## Get started with Swagger!
14-
See the guide on [getting started with swagger](https://github.com/frantuma/swagger-core/wiki/Swagger-2.X---Getting-started) to get started with adding swagger to your API.
14+
See the guide on [getting started with swagger](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Getting-started) to get started with adding swagger to your API.
1515

1616
## See the Wiki!
1717
The [github wiki](https://github.com/swagger-api/swagger-core/wiki) contains documentation, samples, contributions, etc. Start there.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
2+
# Created by https://www.gitignore.io/api/java,gradle,intellij
3+
4+
### Intellij ###
5+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
6+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7+
8+
# User-specific stuff:
9+
.idea/**/workspace.xml
10+
.idea/**/tasks.xml
11+
.idea/dictionaries
12+
13+
# Sensitive or high-churn files:
14+
.idea/**/dataSources/
15+
.idea/**/dataSources.ids
16+
.idea/**/dataSources.xml
17+
.idea/**/dataSources.local.xml
18+
.idea/**/sqlDataSources.xml
19+
.idea/**/dynamic.xml
20+
.idea/**/uiDesigner.xml
21+
22+
# Gradle:
23+
.idea/**/gradle.xml
24+
.idea/**/libraries
25+
26+
# CMake
27+
cmake-build-debug/
28+
29+
# Mongo Explorer plugin:
30+
.idea/**/mongoSettings.xml
31+
32+
## File-based project format:
33+
*.iws
34+
35+
## Plugin-specific files:
36+
37+
# IntelliJ
38+
/out/
39+
40+
# mpeltonen/sbt-idea plugin
41+
.idea_modules/
42+
43+
# JIRA plugin
44+
atlassian-ide-plugin.xml
45+
46+
# Cursive Clojure plugin
47+
.idea/replstate.xml
48+
49+
# Ruby plugin and RubyMine
50+
/.rakeTasks
51+
52+
# Crashlytics plugin (for Android Studio and IntelliJ)
53+
com_crashlytics_export_strings.xml
54+
crashlytics.properties
55+
crashlytics-build.properties
56+
fabric.properties
57+
58+
### Intellij Patch ###
59+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
60+
61+
# *.iml
62+
# modules.xml
63+
# .idea/misc.xml
64+
# *.ipr
65+
66+
# Sonarlint plugin
67+
.idea/sonarlint
68+
69+
### Java ###
70+
# Compiled class file
71+
*.class
72+
73+
# Log file
74+
*.log
75+
76+
# BlueJ files
77+
*.ctxt
78+
79+
# Mobile Tools for Java (J2ME)
80+
.mtj.tmp/
81+
82+
# Package Files #
83+
*.jar
84+
*.war
85+
*.ear
86+
*.zip
87+
*.tar.gz
88+
*.rar
89+
90+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
91+
hs_err_pid*
92+
93+
### Gradle ###
94+
.gradle
95+
**/build/
96+
97+
# Ignore Gradle GUI config
98+
gradle-app.setting
99+
100+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
101+
!gradle-wrapper.jar
102+
103+
# Cache of project
104+
.gradletasknamecache
105+
106+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
107+
# gradle/wrapper/gradle-wrapper.properties
108+
109+
110+
# End of https://www.gitignore.io/api/java,gradle,intellij
111+
112+
.idea/modules
113+
# IntelliJ IDEA
114+
.idea/
115+
*.iml
116+
*.iws
117+
*.ipr
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# swagger-gradle-plugin
2+
3+
## Installation
4+
### Gradle 2.1 and higher
5+
6+
```
7+
plugins {
8+
id "io.swagger.core.v3.swagger-gradle-plugin" version "2.0.5-SNAPSHOT"
9+
}
10+
```
11+
### Gradle 1.x and 2.0
12+
13+
```
14+
buildscript {
15+
repositories {
16+
maven {
17+
url "https://plugins.gradle.org/m2/"
18+
}
19+
}
20+
dependencies {
21+
classpath "gradle.plugin.io.swagger.core.v3.swagger-gradle-plugin:2.0.5-SNAPSHOT"
22+
}
23+
}
24+
25+
apply plugin: "io.swagger.core.v3.swagger-gradle-plugin"
26+
```
27+
28+
## Tasks
29+
### resolve
30+
31+
* Resolves project openAPI specification and saves the result in JSON, YAML or both formats.
32+
All parameters except `outputFileName`, `outputFormat`, `classpath`, `skip`, `encoding` and `outputPath` correspond
33+
to `swagger` [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties) with same name.
34+
35+
#### Example Usage
36+
37+
```
38+
39+
resolve {
40+
outputFileName = 'PetStoreAPI'
41+
outputFormat = 'JSON'
42+
prettyPrint = 'TRUE'
43+
classpath = sourceSets.main.runtimeClasspath
44+
resourcePackages = ['io.test']
45+
outputPath = 'test'
46+
}
47+
```
48+
49+
#### Parameters
50+
Parameter | Description | Required | Default
51+
--------- | ----------- | --------- | -------
52+
`classpath`|classpath for resources to scan (swagger and deps already included in classpath)|true|
53+
`outputPath`|output path where file(s) are saved|true|
54+
`outputFileName`|file name (no extension)|false|`openapi`
55+
`outputFormat`|file format (`JSON`, `YAML`, `JSONANDYAML`|false|`JSON`
56+
`skip`|if `TRUE` skip execution|false|`FALSE`
57+
`encoding`|encoding of output file(s)|false|
58+
`resourcePackages`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
59+
`resourceClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
60+
`prettyPrint`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|`TRUE`
61+
`openApiFile`|openapi file to be merged with resolved specification, see [config](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
62+
`filterClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
63+
`readerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
64+
`scannerClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
65+
`readAllResources`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
66+
`ignoredRoutes`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
67+
68+
***
69+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// * * * * * * * * * * * *
2+
// Plugins
3+
// * * * * * * * * * * * *
4+
plugins {
5+
id 'groovy'
6+
id 'java-gradle-plugin'
7+
id 'net.researchgate.release' version '2.6.0'
8+
// Publishing publicly
9+
id 'com.gradle.plugin-publish' version '0.10.0'
10+
// Publishing to maven
11+
id 'maven-publish'
12+
}
13+
14+
// * * * * * * * * * * * *
15+
// Dependencies
16+
// * * * * * * * * * * * *
17+
18+
repositories {
19+
jcenter()
20+
mavenLocal()
21+
mavenCentral()
22+
}
23+
24+
dependencies {
25+
compile gradleApi()
26+
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.7'
27+
compile group: 'io.swagger.core.v3', name: 'swagger-jaxrs2', version:'2.0.5-SNAPSHOT'
28+
compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version:'2.1'
29+
compile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.1.0'
30+
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version:'2.14.0'
31+
testCompile gradleTestKit()
32+
testCompile 'junit:junit:4+'
33+
34+
35+
}
36+
37+
// * * * * * * * * * * * *
38+
// Project configuration
39+
// * * * * * * * * * * * *
40+
41+
project.description = 'Gradle Plugin for Swagger core'
42+
project.group = 'io.swagger.core.v3'
43+
44+
project.ext.name = 'swagger-gradle-plugin'
45+
project.ext.pluginId = 'io.swagger.core.v3.swagger-gradle-plugin'
46+
project.ext.scm = 'scm:[email protected]:swagger-api/swagger-core.git'
47+
project.ext.url = 'https://github.com/swagger-api/swagger-core/modules/swagger-gradle-plugin'
48+
49+
// Configuration for: java-gradle-plugin
50+
gradlePlugin {
51+
plugins {
52+
swagger {
53+
id = project.pluginId
54+
implementationClass = 'io.swagger.v3.plugins.gradle.SwaggerPlugin'
55+
}
56+
}
57+
}
58+
59+
// * * * * * * * * * * * *
60+
// Publishing
61+
// * * * * * * * * * * * *
62+
63+
64+
// Publishing to plugins.gradle.org
65+
// --------------------------------
66+
67+
// Configuration for: com.gradle.plugin-publish
68+
pluginBundle {
69+
website = project.url
70+
vcsUrl = project.scm
71+
tags = ['swagger', 'openapi', 'api']
72+
73+
plugins {
74+
swagger {
75+
displayName = 'Swagger Gradle Plugin '
76+
description = project.description
77+
id = project.pluginId
78+
}
79+
}
80+
}
81+
82+
publishing {
83+
repositories {
84+
maven {
85+
url mavenLocal().url
86+
}
87+
}
88+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=2.0.5-SNAPSHOT
53.1 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Jun 21 16:50:21 IST 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 commit comments

Comments
 (0)