Compare commits

..

173 Commits

Author SHA1 Message Date
ShubhamRwt
c2597a585e Publish of Github pages from Gradle. 2022-03-01 00:38:53 +05:30
Travis CI User
4df779b4cc Publish of Github pages from Gradle. 2019-03-21 14:46:25 +00:00
Travis CI User
8b9d3fe588 Publish of Github pages from Gradle. 2019-03-21 14:45:30 +00:00
Travis CI User
4d4f4ad7d2 Publish of Github pages from Gradle. 2018-11-21 12:08:28 +00:00
Travis CI User
40467c0186 Publish of Github pages from Gradle. 2018-11-05 09:47:30 +00:00
Travis CI User
a2dc4080d5 Publish of Github pages from Gradle. 2018-10-22 18:25:29 +00:00
Travis CI User
76dced1209 Publish of Github pages from Gradle. 2018-10-18 07:25:26 +00:00
Travis CI User
1060b78622 Publish of Github pages from Gradle. 2018-10-15 08:19:24 +00:00
Travis CI User
23d3f336d5 Publish of Github pages from Gradle. 2018-08-06 10:54:24 +00:00
Travis CI User
5a70512c23 Publish of Github pages from Gradle. 2018-08-06 08:34:24 +00:00
Travis CI User
3c94b8605f Publish of Github pages from Gradle. 2018-07-12 13:28:18 +00:00
Travis CI User
e17311bd7e Publish of Github pages from Gradle. 2018-05-01 19:39:44 +00:00
Travis CI User
fecb5e2e61 Publish of Github pages from Gradle. 2018-04-29 09:46:16 +00:00
Travis CI User
79629d11ae Publish of Github pages from Gradle. 2018-04-27 11:47:33 +00:00
Robert Winkler
6f1efabf94 Publish of Github pages from Gradle. 2018-04-27 11:39:52 +00:00
Travis CI User
393bbe10fd Publish of Github pages from Gradle. 2017-10-09 09:00:12 +00:00
Travis CI User
ab0ce79172 Publish of Github pages from Gradle. 2017-10-05 17:44:55 +00:00
travis
1311ce90b9 Publish of Github pages from Gradle. 2017-07-20 14:37:35 +00:00
travis
e19ed182ff Publish of Github pages from Gradle. 2017-07-17 07:18:40 +00:00
travis
8797e00321 Publish of Github pages from Gradle. 2017-07-17 07:17:54 +00:00
travis
1721a95e07 Publish of Github pages from Gradle. 2017-07-11 07:09:07 +00:00
travis
dac7550bcc Publish of Github pages from Gradle. 2017-05-15 11:08:59 +00:00
travis
44c0507b4e Publish of Github pages from Gradle. 2017-05-15 06:49:19 +00:00
travis
e69b8295dd Publish of Github pages from Gradle. 2017-03-20 11:36:59 +00:00
travis
e8cec2467b Publish of Github pages from Gradle. 2017-03-20 11:33:58 +00:00
Robert Winkler
2cf2593e96 Publish of Github pages from Gradle. 2017-03-20 12:33:47 +01:00
travis
f1a1e52988 Publish of Github pages from Gradle. 2017-03-20 11:32:21 +00:00
travis
820d6dcb47 Publish of Github pages from Gradle. 2017-03-17 08:28:47 +00:00
travis
ea7643fc67 Publish of Github pages from Gradle. 2017-03-16 08:04:55 +00:00
travis
72b84a184e Publish of Github pages from Gradle. 2017-03-14 15:46:39 +00:00
travis
42b0cf8cf0 Publish of Github pages from Gradle. 2017-02-20 07:45:53 +00:00
travis
b0390b1f9a Publish of Github pages from Gradle. 2017-02-20 07:43:57 +00:00
travis
634598c5d4 Publish of Github pages from Gradle. 2017-02-20 07:42:15 +00:00
travis
e08de663d5 Publish of Github pages from Gradle. 2017-02-20 07:41:36 +00:00
Robert Winkler
76347aa49e Publish of Github pages from Gradle. 2017-02-20 08:36:53 +01:00
travis
b0d6183de3 Publish of Github pages from Gradle. 2017-02-03 08:37:29 +00:00
travis
67fe8f70b3 Publish of Github pages from Gradle. 2017-02-03 08:11:18 +00:00
travis
8bcbb5fcfa Publish of Github pages from Gradle. 2017-02-02 08:00:52 +00:00
travis
972497a9a5 Publish of Github pages from Gradle. 2017-01-21 09:37:50 +00:00
travis
fbb98fb446 Publish of Github pages from Gradle. 2017-01-19 13:28:45 +00:00
travis
27a34c519b Publish of Github pages from Gradle. 2017-01-19 13:21:53 +00:00
travis
8ab88d95c8 Publish of Github pages from Gradle. 2017-01-19 09:27:37 +00:00
travis
ca60025907 Publish of Github pages from Gradle. 2017-01-18 11:01:05 +00:00
travis
184b0222a3 Publish of Github pages from Gradle. 2017-01-18 10:55:07 +00:00
travis
b6f4cec736 Publish of Github pages from Gradle. 2017-01-17 09:46:43 +00:00
travis
66fad7ea30 Publish of Github pages from Gradle. 2017-01-13 13:16:54 +00:00
travis
57fa494b95 Publish of Github pages from Gradle. 2017-01-13 13:16:12 +00:00
travis
5ec39bba49 Publish of Github pages from Gradle. 2017-01-13 13:15:29 +00:00
travis
9ecad42092 Publish of Github pages from Gradle. 2017-01-13 13:15:23 +00:00
travis
8914176db0 Publish of Github pages from Gradle. 2017-01-13 12:56:11 +00:00
travis
66757a39fd Publish of Github pages from Gradle. 2017-01-13 12:55:55 +00:00
travis
05818f8abf Publish of Github pages from Gradle. 2017-01-09 11:23:23 +00:00
travis
f6edc96b49 Publish of Github pages from Gradle. 2017-01-05 13:33:25 +00:00
travis
5818025e65 Publish of Github pages from Gradle. 2017-01-05 13:33:07 +00:00
Robert Winkler
cd4a65c3d8 Publish of Github pages from Gradle. 2017-01-05 14:28:10 +01:00
travis
6f0e33c6d5 Publish of Github pages from Gradle. 2017-01-03 15:04:35 +00:00
travis
8a4ec35d47 Publish of Github pages from Gradle. 2017-01-03 14:31:53 +00:00
travis
319a8b68a8 Publish of Github pages from Gradle. 2017-01-03 10:25:50 +00:00
travis
109710b94e Publish of Github pages from Gradle. 2017-01-02 12:50:46 +00:00
travis
f02606abfc Publish of Github pages from Gradle. 2016-12-20 13:10:53 +00:00
travis
324f9a719c Publish of Github pages from Gradle. 2016-12-19 15:08:47 +00:00
travis
ac8332f1ed Publish of Github pages from Gradle. 2016-12-13 09:48:01 +00:00
travis
0cc153d896 Publish of Github pages from Gradle. 2016-12-13 09:02:35 +00:00
travis
9652d91723 Publish of Github pages from Gradle. 2016-12-09 08:21:39 +00:00
travis
dfab76f1c2 Publish of Github pages from Gradle. 2016-11-30 08:22:40 +00:00
Robert Winkler
711886bb90 Publish of Github pages from Gradle. 2016-11-30 09:17:48 +01:00
Robert Winkler
4f001e104f Publish of Github pages from Gradle. 2016-11-30 09:16:40 +01:00
travis
2befad39d0 Publish of Github pages from Gradle. 2016-11-30 08:12:17 +00:00
travis
223250693c Publish of Github pages from Gradle. 2016-11-18 11:41:40 +00:00
travis
8e6737fe79 Publish of Github pages from Gradle. 2016-11-16 11:58:01 +00:00
travis
667bd30dfd Publish of Github pages from Gradle. 2016-11-15 13:54:25 +00:00
travis
4a6c1a6e32 Publish of Github pages from Gradle. 2016-11-15 10:16:09 +00:00
travis
b365766cb4 Publish of Github pages from Gradle. 2016-11-14 15:21:40 +00:00
travis
7279daf5df Publish of Github pages from Gradle. 2016-11-11 13:26:54 +00:00
travis
5af951598d Publish of Github pages from Gradle. 2016-11-10 11:48:01 +00:00
travis
ffa27aa177 Publish of Github pages from Gradle. 2016-11-09 15:35:07 +00:00
travis
57a61ce839 Publish of Github pages from Gradle. 2016-11-04 14:38:15 +00:00
travis
a6576761c7 Publish of Github pages from Gradle. 2016-11-02 07:52:04 +00:00
travis
c427efaca3 Publish of Github pages from Gradle. 2016-11-01 13:51:22 +00:00
travis
ff2e3654c1 Publish of Github pages from Gradle. 2016-11-01 08:01:19 +00:00
travis
86b7577fd0 Publish of Github pages from Gradle. 2016-11-01 06:10:51 +00:00
travis
dd04f559d5 Publish of Github pages from Gradle. 2016-10-28 07:14:15 +00:00
travis
d828ab31f9 Publish of Github pages from Gradle. 2016-10-25 13:33:40 +00:00
travis
586596c5a1 Publish of Github pages from Gradle. 2016-10-18 13:47:49 +00:00
travis
00e723fbb8 Publish of Github pages from Gradle. 2016-10-18 13:35:44 +00:00
travis
5f844db4c5 Publish of Github pages from Gradle. 2016-10-18 13:26:17 +00:00
travis
fe93add209 Publish of Github pages from Gradle. 2016-10-14 05:17:51 +00:00
travis
753ad57059 Publish of Github pages from Gradle. 2016-10-12 06:53:21 +00:00
travis
c2a8d0d5eb Publish of Github pages from Gradle. 2016-10-03 11:52:30 +00:00
travis
36958d78aa Publish of Github pages from Gradle. 2016-09-23 08:37:11 +00:00
travis
704e20ef5c Publish of Github pages from Gradle. 2016-09-23 08:27:38 +00:00
travis
0104b8cfe8 Publish of Github pages from Gradle. 2016-09-23 07:00:22 +00:00
travis
43292024b6 Publish of Github pages from Gradle. 2016-09-14 08:02:58 +00:00
travis
ca8cc35004 Publish of Github pages from Gradle. 2016-09-12 08:08:19 +00:00
travis
f427e77b78 Publish of Github pages from Gradle. 2016-09-12 07:56:01 +00:00
travis
4d876c33a6 Publish of Github pages from Gradle. 2016-08-31 08:29:02 +00:00
travis
04f6239fd3 Publish of Github pages from Gradle. 2016-08-25 11:56:37 +00:00
travis
156f1ce880 Publish of Github pages from Gradle. 2016-08-12 18:06:22 +00:00
travis
836fcd6829 Publish of Github pages from Gradle. 2016-08-04 10:16:16 +00:00
travis
4a741acda2 Publish of Github pages from Gradle. 2016-08-04 08:37:40 +00:00
travis
857dd34992 Publish of Github pages from Gradle. 2016-08-04 08:20:52 +00:00
travis
84ad0ccaa7 Publish of Github pages from Gradle. 2016-08-04 08:15:23 +00:00
travis
128710cf50 Publish of Github pages from Gradle. 2016-08-04 08:14:44 +00:00
Robert Winkler
26cd23941a Publish of Github pages from Gradle. 2016-08-04 10:06:56 +02:00
Robert Winkler
d51684196d Publish of Github pages from Gradle. 2016-08-04 09:55:43 +02:00
travis
3f2f91f134 Publish of Github pages from Gradle. 2016-08-03 08:18:53 +00:00
travis
c62bcb02c2 Publish of Github pages from Gradle. 2016-07-30 18:37:46 +00:00
travis
de76eac12e Publish of Github pages from Gradle. 2016-06-01 13:05:39 +00:00
travis
dee68deb4d Publish of Github pages from Gradle. 2016-05-29 05:16:30 +00:00
travis
df4b6b8684 Publish of Github pages from Gradle. 2016-05-28 19:23:56 +00:00
travis
b49b7e01b9 Publish of Github pages from Gradle. 2016-05-28 18:55:43 +00:00
travis
12d3a5569a Publish of Github pages from Gradle. 2016-05-28 18:54:01 +00:00
travis
839a67aa18 Publish of Github pages from Gradle. 2016-05-28 18:53:07 +00:00
travis
c9a4e174db Publish of Github pages from Gradle. 2016-05-28 18:40:39 +00:00
travis
92adc61544 Publish of Github pages from Gradle. 2016-05-28 18:31:39 +00:00
travis
de24d5811c Publish of Github pages from Gradle. 2016-05-28 18:30:21 +00:00
travis
35e953d6b2 Publish of Github pages from Gradle. 2016-05-28 18:26:24 +00:00
travis
2728708af3 Publish of Github pages from Gradle. 2016-05-26 14:28:17 +00:00
travis
6f75fb6649 Publish of Github pages from Gradle. 2016-05-26 11:28:28 +00:00
travis
19dc822316 Publish of Github pages from Gradle. 2016-05-26 09:30:26 +00:00
travis
94d08b24d1 Publish of Github pages from Gradle. 2016-05-26 06:29:44 +00:00
travis
0a92457e41 Publish of Github pages from Gradle. 2016-05-24 12:26:44 +00:00
travis
03f19e7c25 Publish of Github pages from Gradle. 2016-05-12 08:01:55 +00:00
travis
4ddab7c8be Publish of Github pages from Gradle. 2016-05-04 19:11:52 +00:00
travis
101883f3b3 Publish of Github pages from Gradle. 2016-05-02 11:29:16 +00:00
travis
49da3d0fef Publish of Github pages from Gradle. 2016-05-02 11:13:15 +00:00
travis
6858dcd424 Publish of Github pages from Gradle. 2016-04-19 11:14:15 +00:00
travis
21e37a8cb3 Publish of Github pages from Gradle. 2016-04-19 08:58:24 +00:00
travis
7f116674b5 Publish of Github pages from Gradle. 2016-04-19 08:44:28 +00:00
travis
9c31fc416c Publish of Github pages from Gradle. 2016-04-15 10:29:41 +00:00
travis
0da081c0b4 Publish of Github pages from Gradle. 2016-04-14 15:57:42 +00:00
travis
d4973918f6 Publish of Github pages from Gradle. 2016-04-14 14:52:22 +00:00
travis
0ecda51555 Publish of Github pages from Gradle. 2016-04-14 14:47:54 +00:00
travis
de26a4fec3 Publish of Github pages from Gradle. 2016-04-14 13:59:44 +00:00
travis
f6481a7f21 Publish of Github pages from Gradle. 2016-04-14 13:39:05 +00:00
travis
f5291e3450 Publish of Github pages from Gradle. 2016-04-14 10:43:33 +00:00
Robert Winkler
ddf3265d4b Publish of Github pages from Gradle. 2016-04-13 14:23:51 +02:00
Robert Winkler
653420fa02 Publish of Github pages from Gradle. 2016-04-13 14:07:15 +02:00
Robert Winkler
a98247adb4 Publish of Github pages from Gradle. 2016-04-12 16:06:31 +02:00
Robert Winkler
f26ba312a7 Publish of Github pages from Gradle. 2016-04-06 13:05:42 +02:00
Robert Winkler
447c4ca3c2 Publish of Github pages from Gradle. 2016-04-06 09:31:48 +02:00
Robert Winkler
6189f710e1 Publish of Github pages from Gradle. 2016-04-06 09:29:37 +02:00
Robert Winkler
5dcb0a3549 Publish of Github pages from Gradle. 2016-04-06 09:22:13 +02:00
Robert Winkler
060f3f859b Publish of Github pages from Gradle. 2016-04-06 09:04:53 +02:00
Robert Winkler
e465c7ff26 Publish of Github pages from Gradle. 2016-04-06 09:01:57 +02:00
Robert Winkler
152083bfa6 Publish of Github pages from Gradle. 2016-04-06 08:55:35 +02:00
Robert Winkler
5b2c34657e Publish of Github pages from Gradle. 2016-04-06 08:20:04 +02:00
Robert Winkler
d0fba73012 Publish of Github pages from Gradle. 2016-04-06 08:12:44 +02:00
Robert Winkler
1703b26626 Publish of Github pages from Gradle. 2016-04-06 08:01:49 +02:00
Robert Winkler
08e445c579 Publish of Github pages from Gradle. 2016-04-05 15:56:09 +02:00
Robert Winkler
da792f6fb8 Publish of Github pages from Gradle. 2016-04-05 15:54:50 +02:00
Robert Winkler
dd606d65ad Publish of Github pages from Gradle. 2016-04-05 15:53:40 +02:00
Robert Winkler
416aefdaf0 Publish of Github pages from Gradle. 2016-04-05 15:51:30 +02:00
Robert Winkler
b725e7324f Publish of Github pages from Gradle. 2016-04-05 15:47:36 +02:00
Robert Winkler
ffb53aac33 Publish of Github pages from Gradle. 2016-04-05 15:37:14 +02:00
Robert Winkler
cbf1b50107 Publish of Github pages from Gradle. 2016-04-05 15:21:09 +02:00
Robert Winkler
92438b20db Publish of Github pages from Gradle. 2016-04-05 15:14:04 +02:00
Robert Winkler
4134a78185 Publish of Github pages from Gradle. 2016-04-05 15:06:46 +02:00
Robert Winkler
ea8829a288 Publish of Github pages from Gradle. 2016-04-05 15:03:20 +02:00
Robert Winkler
268815ac10 Publish of Github pages from Gradle. 2016-04-05 14:57:10 +02:00
Robert Winkler
4ebfda1e94 Publish of Github pages from Gradle. 2016-04-05 14:53:52 +02:00
Robert Winkler
6c7a9ad46e Publish of Github pages from Gradle. 2016-04-05 13:43:44 +02:00
Robert Winkler
857ae5a3f7 Publish of Github pages from Gradle. 2016-04-05 13:18:16 +02:00
Robert Winkler
b881d7f8b5 Publish of Github pages from Gradle. 2016-04-04 16:39:03 +02:00
Robert Winkler
8014c4ba77 Publish of Github pages from Gradle. 2016-04-04 12:23:24 +02:00
Robert Winkler
8443ddc2dc Publish of Github pages from Gradle. 2016-04-04 11:19:21 +02:00
Robert Winkler
a6cf1b51c6 Publish of Github pages from Gradle. 2016-04-04 11:16:38 +02:00
Robert Winkler
5065d4c744 Publish of Github pages from Gradle. 2016-04-01 15:00:21 +02:00
Robert Winkler
7435dc8e1a Publish of Github pages from Gradle. 2016-04-01 14:56:41 +02:00
Robert Winkler
4eb0ee49f6 Publish of Github pages from Gradle. 2016-03-23 16:32:14 +01:00
Robert Winkler
b8984ca5f5 Publish of Github pages from Gradle. 2016-03-22 16:39:07 +01:00
Robert Winkler
b2bceaece0 Publish of Github pages from Gradle. 2016-03-22 16:34:23 +01:00
Robert Winkler
79446a84f1 Publish of Github pages from Gradle. 2016-03-10 10:06:42 +01:00
540 changed files with 9446 additions and 65702 deletions

8
.gitignore vendored
View File

@@ -1,8 +0,0 @@
.idea
*.iml
.gradle
build
/bin/
/.classpath
/.project
/.settings/

View File

@@ -1,18 +0,0 @@
language: java
jdk:
- openjdk8
before_install:
- chmod +x gradlew
after_success:
- ./gradlew jacocoTestReport coveralls
- ./gradlew artifactoryPublish -PbintrayUsername="${BINTRAY_USER}" -PbintrayApiKey="${BINTRAY_KEY}"
- ./gradlew publishGhPages -PgithubUser="${GITHUB_USER}" -PgithubPassword="${GITHUB_PASSWORD}"
--stacktrace
notifications:
slack: swagger2markup:Zz5kz0SnvtG6aVvZUM8yMkER
env:
global:
- secure: SPKolgUdjIa/uJ+7/B/GPFlsa8IZg7NuZdFA8zROTaqew/xu+oX7qVGImseeBpPIEPJb02ac6hr7Y3/zvv0GJxIPtIbyDzVh73ImQUhT1ttLYGJfITAWqAPFF7RNNMtuOl3S2DLZ5OMJddkcFp00pa9nyI82Gk47B8GsaGIntAI=
- secure: nXXuHfvFACZwdiFM3Ta0x/f49N7cAgi0AMkgEnQrh/2xWlvQk2z2ySGJQLkhJ7Wy8LDY7Yt1b1GUt6DlP3PuFFMW/cT4iARewqiJRXZXxUQz8fpTDeTo1nmVmW/zzII6Qj3QHM3NRbR/xDOVSJiT30Hnq2hcCBQJWYsTICmzjRk=
- secure: Ia/wJ572M2II76roFeGEVCzIiktG4v2j/reSn60fpk1gnoEPQEObL4j1dbVCgXBLz54YWcaQ3mICvOfBPPEl9IIV3Y6DDE2sBOmB3soznfdA/YVnJx0h0f1pfXu1dwqoiv1sgc1wewQuUWq+FV7xeDhFE3cnh9CXIexe9ykip8k=
- secure: GWfhYDsHRmTfOuEOIcHY8kT4jKBTbdhNLDQ/2amY06xenFblb4pEn6pgmn4IdK3ytjNovnZPTOOK8HqdEjhbfIGoQt6PZwuyANn4Df+zdqOC0+V+7DFG2QhEhbRCyEwPlDqTPjxlOMfAmvjFuY/NvQywoF3PYUyMfJwUV8ehmYk=

View File

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

3120
1.3.1/index.html Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

3120
1.3.3/index.html Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

3206
1.3.4/index.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +0,0 @@
Thanks for raising a Swagger2Markup issue. Please provide a brief description of your problem along with the Swagger2Markup version you are using. If possible, please also consider putting together a complete Swagger specification that reproduces the issue. It's better if the Swagger specification is small and isolate the issue.
Swagger2Markup version:
Problem description:

View File

@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,79 +0,0 @@
= Swagger2Markup
:author: Robert Winkler
:hardbreaks:
image:https://travis-ci.org/Swagger2Markup/swagger2markup.svg?branch=master["Build Status", link="https://travis-ci.org/Swagger2Markup/swagger2markup"] image:https://coveralls.io/repos/Swagger2Markup/swagger2markup/badge.svg["Coverage Status", link="https://coveralls.io/r/Swagger2Markup/swagger2markup"] image:https://api.codacy.com/project/badge/grade/498a6a39d7d84ff687546359f58ee18d["Codacy code quality", link="https://www.codacy.com/app/robwin/swagger2markup"] image:https://api.bintray.com/packages/swagger2markup/Maven/swagger2markup/images/download.svg[link="https://bintray.com/swagger2markup/Maven/swagger2markup/_latestVersion"] image:http://img.shields.io/badge/license-ASF2-blue.svg["Apache License 2", link="http://www.apache.org/licenses/LICENSE-2.0.txt"] image:https://img.shields.io/badge/Twitter-rbrtwnklr-blue.svg["Twitter", link="https://twitter.com/rbrtwnklr"] image:https://badges.gitter.im/Join%20Chat.svg[link="https://gitter.im/RobWin/swagger2markup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"]
== Overview
NOTE: Dear community,
unfortunately I can't maintain Swagger2Markup alone anymore. There are many interesting new topics:
1) Swagger v3 support
2) Fixing bugs
2) Merge Swagger2Markup repositories and create a new multi-module repository.
Any help is welcome.
Kind regards,
Robert
The primary goal of this project is to *simplify the generation of an up-to-date RESTful API documentation by combining documentation that's been hand-written with auto-generated API documentation* produced by https://github.com/swagger-api[Swagger]. The result is intended to be an *up-to-date, easy-to-read, on- and offline user guide*, comparable to https://developer.github.com/v3/[GitHub's API documentation]. The output of Swagger2Markup can be used as an alternative to https://github.com/swagger-api/swagger-ui[swagger-ui] and can be served as static content.
NOTE: The Swagger Specification has been donated to to the https://openapis.org/[Open API Initiative (OAI)] and has been renamed to the https://github.com/OAI/OpenAPI-Specification[OpenAPI Specification].
Swagger2Markup converts a Swagger JSON or YAML file into several *AsciiDoc* or *GitHub Flavored Markdown* documents which can be combined with hand-written documentation. The Swagger source file can be located locally or remotely via HTTP. Swagger2Markup supports the Swagger 1.2 and 2.0 specification. Internally it uses the _official_ https://github.com/swagger-api/swagger-parser[swagger-parser] and my https://github.com/RobWin/markup-document-builder[markup-document-builder].
You can use Swagger2Markup to convert your contract-first Swagger YAML file into a human-readable format and combine it with hand-written documentation. As an alternative, you can choose the code-first approach and use Swagger2Markup together with https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-JAX-RS-Project-Setup-1.5.X[Swagger JAX-RS], https://github.com/springfox/springfox[springfox] or https://github.com/spring-projects/spring-restdocs[spring-restdocs]. If you are Gradle or Maven user, you can also use the https://github.com/RobWin/swagger2markup-gradle-plugin[Swagger2Markup Gradle Plugin] or https://github.com/redowl/swagger2markup-maven-plugin[Swagger2markup Maven Plugin].
http://asciidoctor.org/docs/asciidoc-writers-guide/[AsciiDoc] is preferable to Markdown as it has more features. AsciiDoc is a text document format for writing documentation, articles, books, ebooks, slideshows, web pages and blogs. AsciiDoc files can be converted to *HTML*, *PDF* and *EPUB*. AsciiDoc is much better suited for describing public APIs than *JavaDoc* or *Annotations*.
You can generate your HTML5, PDF and EPUB documentation via https://github.com/asciidoctor/asciidoctorj[asciidoctorj] or even better via the https://github.com/asciidoctor/asciidoctor-gradle-plugin[asciidoctor-gradle-plugin] or https://github.com/asciidoctor/asciidoctor-maven-plugin[asciidoctor-maven-plugin].
The project requires at least JDK 8.
== Example
image::swagger2markup-documentation/src/docs/asciidoc/images/Swagger2Markup.PNG[]
image::swagger2markup-documentation/src/docs/asciidoc/images/Swagger2Markup_definitions.PNG[]
== Reference documentation
- http://swagger2markup.github.io/swagger2markup/1.3.3/[Reference Documentation]
- https://github.com/Swagger2Markup/swagger2markup/blob/master/RELEASENOTES.adoc[Release notes]
- https://github.com/Swagger2Markup/spring-swagger2markup-demo[Demo using Swagger2Markup, Spring Boot, Springfox and spring-restdocs]
== Contributing
=== Community contributions
Pull requests are welcome.
=== Questions
You can ask questions about Swagger2Markup in https://gitter.im/Swagger2Markup/swagger2markup[Gitter].
=== Bugs
If you believe you have found a bug, please take a moment to search the existing issues. If no one else has reported the problem, please open a new issue that describes the problem in detail and, ideally, includes a test that reproduces it.
=== Enhancements
If youd like an enhancement to be made to Swagger2Markup, pull requests are most welcome. The source code is on GitHub. You may want to search the existing issues and pull requests to see if the enhancement is already being worked on. You may also want to open a new issue to discuss a possible enhancement before work on it begins.
== Companies who use Swagger2Markup
* Deutsche Telekom AG
* https://restlet.com/[Restlet] -- Restlet offers an API platform, covering the https://restlet.com/products/restlet-studio/[design], https://restlet.com/products/dhc/[test] and https://restlet.com/products/apispark/[operation] of Web APIs, and uses Swagger2Markup to generate appealing HTML documentation from API definitions.
* http://www.qaware.de/[QAware GmbH]
* http://www.appdirect.com/[AppDirect] -- The leading commerce platform for selling cloud services.
* http://www.wescale.com[wescale]
* http://taskassure.com[TaskAssure]
* https://www.isaac.nl[ISAAC]
* https://www.spreadshirt.de[Spreadshirt]
== License
Copyright 2015 Robert Winkler
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

View File

@@ -1,169 +0,0 @@
= Release Notes
== Version 0.1.0
* Initial version with support for AsciiDoc and Markdown
=== Version 0.1.1
* Signed jar files
=== Version 0.1.2
* Removed logback from compile dependency
=== Version 0.1.3
* Removed commons.io from compile dependency
=== Version 0.1.4
* Fixed SECTION_TITLE_LEVEL3 in Markdown enum
=== Version 0.1.5
* Added SECTION_TITLE_LEVEL4
== Version 0.2.0
* This version is not downward compatible. This version supports includes of example files and JSON/XML Schema files. See documentation.
=== Version 0.2.1
* Signed jar files and published in Maven Central
=== Version 0.2.2
* Fixed wrong dependency version to io.github.robwin:markup-document-builder
=== Version 0.2.3
* Fixed issue #7: @ApiModelProperty metadata are ignored for definitions file
=== Version 0.2.4
* Fixed issue #8: logback.xml on the classpath
* Fixed issue #13: unknown format not supported for properties
== Version 0.3.0
* Support of YAML or JSON String as input.
== Version 0.4.0
* Updated Swagger-Parser from 1.0.0 to 1.0.5
* Updated commons-lang to commons-lang3
* Swagger2MarkupConverter generates three documents now: overview, paths and definitions
* Support for enums in HeaderParameter, QueryParameter, FormParameter and QueryParameter
* Support for global consumes, produces and tags
== Version 0.5.0
* Support for including hand-written descriptions instead of using Swagger Annotations for descriptions
=== Version 0.5.1
* Bugfix: Definition name must be lowercase so that descriptions file can be found
=== Version 0.5.2
* Swagger License is not mandatory anymore
* Updated markup-document-builder from v0.1.3 to v0.1.4
=== Version 0.5.3
* Fixed compiler warning: [options] bootstrap class path not set in conjunction with -source 1.7
== Version 0.6.0
* Updated swagger-parser from v1.0.5 to v1.0.6
* Support for default values in Parameters and Model properties
=== Version 0.6.1
* Updated swagger-parser from v1.0.6 to v1.0.8
=== Version 0.6.2
* curl-request.adoc from spring-restdocs is also added to the example chapters
=== Version 0.6.3
* Added possibility to write object definitions to separate files. Issue #19
== Version 0.7.0
* Added support for both reference models and composed models
=== Version 0.7.1
* Workaround: If the type of a BodyParameter is String and not a Model, the schema is null and lost. Therefore the fallback type of a BodyParameter is String now.
== Version 0.8.0
* Enhancement #26 and #27: Added a pre-process hook to modify a Swagger Model before it is converted.
* Bugfix #29: Tags are rendered twice
== Version 0.9.0
* Updated swagger-parser from v1.0.8 to v1.0.13
* Support for global responses and parameters
=== Version 0.9.1
* Added support to group the paths by tags or as-is
* Added support to order the definitions by natural ordering or as-is
=== Version 0.9.2
* Multi language support. Added russian.
=== Version 0.9.3
* Updated swagger-parser from v1.0.13 to v1.0.16
* Enhancement #61: Refactor separated documents logic to support inter-document cross-references
* Enhancement #53: Support for tags, paths and methods ordering
* Enhancement #51: Support for separated operations files
* Enhancement #52: Markdown generation for inline schemas
== Version 1.0.0
* New configuration API
* New extension SPI
* Added new languages: turkish, german, france
* New security document
* Inline schema support
* New configuration options
* Support of deprecated path operations
=== Version 1.0.1
* Enhancement: Support to render validation constraints of properties
* Enhancement: Possibility to disable rendering of the security chapter below operations
== Version 1.1.0
* PR #177: Fixed rendering of recursive examples
* PR #186: Add support for Chinese language
* PR #190: Add support for Spanish language
* PR #192: Updated min/max value to format correctly based on the data type
* PR #193: Added support for exclusiveMin and exclusiveMax
* Changed bold to ** and italic to __ so that special chars in the text are possible
=== Version 1.1.1
* Issue #194: Added a config parameter which allows to prepend the basePath to all paths.
* Updated swagger-parser from v1.0.16 to v1.0.23
* Added javslang v2.0.4 as a dependency
* Added paleo-core v0.10.1 as a dependency
* Updated markup-document-builder from 1.0.0 to 1.1.0
* PR #201: Add support for Brazilian Portuguese language
* PR #202: Add support for Japanese language
* Issue #205: Fixed the option to influence resource ordering
* Issue #198: Chinese chinese language encoding
* Issue #207: Properties that start with an underscore are displayed correctly now
* Refactored Swagger2Markup to use a Component-Based design. A document can be composed of components and components can be composed of other components.
* Added a method to add page breaks.
== Version 1.1.2
* Improve code blocks in markdown
== Version 1.2.0
* Issue #214: Add page break locations
* Issue #223: Improve example rendering
* Issue #215: Add ability to group operations by RegEx
* Added new configuration options: pageBreakLocations, headerRegex
* Added new valid value for configuration headerRegex: REGEX
* Updated markup-document-builder from 1.1.0 to 1.1.1
== Version 1.3.0
* Updated javslang from 2.0.4 to 2.0.5
* Updated paleo-core from 0.10.1 to 0.10.2
* Updated swagger-parser from v1.0.23 to v1.0.25
* Decimal numbers are formatted into locale-specific strings
=== Version 1.3.1
* PR #247: Fix request path and query params example support.
=== Version 1.3.2
* PR #290: Fixed list parsing in properties file
* PR #293: Fixed crash on empty tables
* Updated markup-document-builder from 1.1.1 to 1.1.2
=== Version 1.3.3
* Updated swagger-parser from v1.0.25 to 1.0.35
* PR #294: Examples always start with a newline if there is other content in the same cell
* PR 307: Include required parameters in example request
=== Version 2.0.0
* Added openapi2markup to support OpenAPI v3
* Issue #409: Fixed JSON response example

View File

@@ -1,119 +0,0 @@
plugins {
id "org.sonarqube" version "2.7"
id "me.champeau.gradle.jmh" version "0.4.8"
id 'org.asciidoctor.convert' version '1.6.0'
id "org.ajoberstar.github-pages" version "1.7.2"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}
apply plugin: 'idea'
apply from: "${rootDir}/libraries.gradle"
ext {
releaseVersion = '1.3.3'
}
allprojects {
apply plugin: 'jacoco'
apply plugin: 'me.champeau.gradle.jmh'
version = '2.0.0-SNAPSHOT'
group 'io.github.swagger2markup'
description = 'swagger2markup Build'
repositories {
jcenter()
mavenCentral()
maven {
name "OSS Snapshots"
url "https://oss.jfrog.org/artifactory/oss-snapshot-local"
}
}
}
//artifactoryPublish.skip = true // apply to all projects except the root
ext {
coreProjects = subprojects.findAll {
p -> !p.name.contains("documentation") && !p.name.endsWith("-bom")
}
}
configure(project.coreProjects) {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply from: "${rootDir}/publishing.gradle"
apply plugin: 'jacoco'
tasks.withType(JavaCompile) {
sourceCompatibility = "11"
targetCompatibility = "11"
options.deprecation = true
options.encoding = 'UTF-8'
options.compilerArgs += ["-Xlint:unchecked", "-parameters"]
}
tasks.withType(Javadoc){
options.encoding = 'UTF-8'
}
jmh {
duplicateClassesStrategy = 'warn'
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
}
}
nexusPublishing {
repositories {
sonatype()
}
}
sonarqube {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.projectName", "swagger2markup"
property "sonar.projectKey", "swagger2markup_swagger2markup"
property "sonar.links.homepage", "https://github.com/Swagger2Markup/swagger2markup"
property "sonar.links.ci", "https://travis-ci.org/Swagger2Markup/swagger2markup"
property "sonar.links.scm", "https://github.com/Swagger2Markup/swagger2markup"
property "sonar.links.issue", "https://github.com/Swagger2Markup/swagger2markup/issues"
property "sonar.language", "java"
}
}
def allTestCoverageFile = "$buildDir/jacoco/allTestCoverage.exec"
task jacocoMergeTest(type: JacocoMerge) {
destinationFile = file(allTestCoverageFile)
executionData = project.fileTree(dir: '.', include: '**/build/jacoco/test.exec')
}
task jacocoMerge(dependsOn: ['jacocoMergeTest']) {
// used to run the other merge tasks
}
subprojects {
sonarqube {
properties {
property "sonar.jacoco.reportPaths", allTestCoverageFile
}
}
afterEvaluate {
// exclude subprojects that don't produce a jar file or by design.
if (!project.name.equals('swagger2markup-bom') && !project.name.equals('swagger2markup-documentation')) {
jar {
inputs.property('moduleName', moduleName)
manifest.attributes(
'Automatic-Module-Name': moduleName
)
}
}
}
}
tasks.check.dependsOn tasks.jacocoTestReport
test {
dependsOn(subprojects.test) // required by cobertura to aggregate report
}

View File

@@ -1,2 +0,0 @@
systemProp.file.encoding=UTF-8
systemProp.sun.jnu.encoding=UTF-8

Binary file not shown.

View File

@@ -1,6 +0,0 @@
#Mon Oct 21 16:35:38 BST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip

172
gradlew vendored
View File

@@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored
View File

@@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,52 +0,0 @@
// Allows centralized definition of the version of artifacts to
// use. In that respect it serves a role similar to <dependencyManagement> in Maven
ext {
implLibraries = [:]
testLibraries = [:]
dependencyOverrides = [:]
}
implLibraries = [
asciiDocJApi : "org.asciidoctor:asciidoctorj-api:2.2.0",
commonsBeanUtils : "commons-beanutils:commons-beanutils:1.9.4",
commonsCodec : "commons-codec:commons-codec:1.13",
commonsCollections4: "org.apache.commons:commons-collections4:4.4",
commonsConf2 : "org.apache.commons:commons-configuration2:2.6",
commonsLang3 : "org.apache.commons:commons-lang3:3.9",
commonsIO : "commons-io:commons-io:2.6",
commonsText : "org.apache.commons:commons-text:1.8",
guava : 'com.google.guava:guava:27.0.1-android',
jacksonDatabind : 'com.fasterxml.jackson.core:jackson-databind:2.9.10',
mark2Ascii : "nl.jworks.markdown_to_asciidoc:markdown_to_asciidoc:1.1",
paleo : "ch.netzwerg:paleo-core:0.14.0",
pegdown : "org.pegdown:pegdown:1.6.0",
slf4j : "org.slf4j:slf4j-api:1.7.28",
swaggerV2 : "io.swagger:swagger-parser:1.0.47",
swaggerV2Converter : "io.swagger.parser.v3:swagger-parser-v2-converter:2.0.15",
swaggerV3 : "io.swagger.parser.v3:swagger-parser:2.0.15",
vavr : "io.vavr:vavr:0.10.2"
]
testLibraries = [
asciiDocJ : "org.asciidoctor:asciidoctorj:2.2.0",
assertj : "org.assertj:assertj-core:3.13.2",
assertjDiff: "io.github.robwin:assertj-diff:0.1.1",
junit : "junit:junit:4.12",
logback : "ch.qos.logback:logback-classic:1.2.3",
mockito : "org.mockito:mockito-core:3.1.0"
]
dependencyOverrides = [
assertj : testLibraries.assertj,
commonsCodec : implLibraries.commonsCodec,
commonsIO : implLibraries.commonsIO,
commonsLang3 : implLibraries.commonsLang3,
findBugs : 'com.google.code.findbugs:jsr305:3.0.2',
guava : implLibraries.guava,
jaksonCore : 'com.github.fge:jackson-coreutils:1.8',
jacksonDatabind: implLibraries.jacksonDatabind,
jnrConstants : 'com.github.jnr:jnr-constants:0.9.12',
jnrEnxio : 'com.github.jnr:jnr-enxio:0.19',
jnrPosix : 'com.github.jnr:jnr-posix:3.0.49',
jodaTime : 'joda-time:joda-time:2.9.9',
slf4j : implLibraries.slf4j,
]

View File

@@ -1,34 +0,0 @@
ext.moduleName="io.github.swagger2markup.openapi2markup"
dependencies {
configurations.all {
resolutionStrategy.force dependencyOverrides.commonsCodec
resolutionStrategy.force dependencyOverrides.commonsIO
resolutionStrategy.force dependencyOverrides.commonsLang3
resolutionStrategy.force dependencyOverrides.jnrConstants
resolutionStrategy.force dependencyOverrides.jnrEnxio
resolutionStrategy.force dependencyOverrides.jnrPosix
resolutionStrategy.force dependencyOverrides.jodaTime
resolutionStrategy.force dependencyOverrides.slf4j
resolutionStrategy.force dependencyOverrides.jacksonDatabind
resolutionStrategy.force dependencyOverrides.guava
resolutionStrategy.force dependencyOverrides.findBugs
resolutionStrategy.force dependencyOverrides.jaksonCore
resolutionStrategy.force dependencyOverrides.assertj
}
// implementation implLibraries.swaggerV2Converter
compile project(':swagger2markup-asciidoc')
compile project(':swagger2markup-core')
implementation implLibraries.asciiDocJApi
implementation implLibraries.commonsText
implementation implLibraries.commonsBeanUtils
implementation implLibraries.slf4j
implementation implLibraries.swaggerV3
implementation implLibraries.commonsCollections4
implementation implLibraries.commonsConf2
implementation implLibraries.vavr
testImplementation testLibraries.assertj
testImplementation testLibraries.assertjDiff
testImplementation testLibraries.junit
testImplementation testLibraries.logback
}

View File

@@ -1,378 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup;
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
import io.github.swagger2markup.config.OpenAPILabels;
import io.github.swagger2markup.config.builder.OpenAPI2MarkupConfigBuilder;
import io.github.swagger2markup.extension.OpenAPI2MarkupExtensionRegistry;
import io.github.swagger2markup.extension.builder.OpenAPI2MarkupExtensionRegistryBuilder;
import io.github.swagger2markup.internal.document.ComponentsDocument;
import io.github.swagger2markup.internal.document.OverviewDocument;
import io.github.swagger2markup.internal.document.PathsDocument;
import io.github.swagger2markup.internal.document.SecurityDocument;
import io.github.swagger2markup.utils.URIUtils;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.OpenAPIV3Parser;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class OpenAPI2MarkupConverter extends AbstractSchema2MarkupConverter<OpenAPI> {
private final OverviewDocument overviewDocument;
private final PathsDocument pathsDocument;
private final ComponentsDocument componentsDocument;
private final SecurityDocument securityDocument;
private final OpenAPIContext openAPIContext;
public OpenAPI2MarkupConverter(OpenAPIContext context) {
super(context);
this.openAPIContext = context;
this.overviewDocument = new OverviewDocument(context);
this.pathsDocument = new PathsDocument(context);
this.componentsDocument = new ComponentsDocument(context);
this.securityDocument = new SecurityDocument(context);
}
/**
* Creates a OpenAPI2MarkupConverter.Builder from a URI.
*
* @param swaggerUri the URI
* @return a OpenAPI2MarkupConverter
*/
public static Builder from(URI swaggerUri) {
Validate.notNull(swaggerUri, "swaggerUri must not be null");
String scheme = swaggerUri.getScheme();
if (scheme != null && swaggerUri.getScheme().startsWith("http")) {
try {
return from(swaggerUri.toURL());
} catch (MalformedURLException e) {
throw new RuntimeException("Failed to convert URI to URL", e);
}
} else if (scheme != null && swaggerUri.getScheme().startsWith("file")) {
return from(Paths.get(swaggerUri));
} else {
return from(URIUtils.convertUriWithoutSchemeToFileScheme(swaggerUri));
}
}
/**
* Creates a OpenAPI2MarkupConverter.Builder using a remote URL.
*
* @param swaggerURL the remote URL
* @return a OpenAPI2MarkupConverter
*/
public static Builder from(URL swaggerURL) {
Validate.notNull(swaggerURL, "swaggerURL must not be null");
return new Builder(swaggerURL);
}
/**
* Creates a OpenAPI2MarkupConverter.Builder using a local Path.
*
* @param swaggerPath the local Path
* @return a OpenAPI2MarkupConverter
*/
public static Builder from(Path swaggerPath) {
Validate.notNull(swaggerPath, "swaggerPath must not be null");
if (Files.notExists(swaggerPath)) {
throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
}
try {
if (Files.isHidden(swaggerPath)) {
throw new IllegalArgumentException("swaggerPath must not be a hidden file");
}
} catch (IOException e) {
throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
}
return new Builder(swaggerPath);
}
/**
* Creates a OpenAPI2MarkupConverter.Builder from a given Swagger model.
*
* @param openAPI the Swagger source.
* @return a OpenAPI2MarkupConverter
*/
public static Builder from(OpenAPI openAPI) {
Validate.notNull(openAPI, "schema must not be null");
return new Builder(openAPI);
}
/**
* Creates a OpenAPI2MarkupConverter.Builder from a given Swagger YAML or JSON String.
*
* @param swaggerString the Swagger YAML or JSON String.
* @return a OpenAPI2MarkupConverter
*/
public static Builder from(String swaggerString) {
Validate.notEmpty(swaggerString, "swaggerString must not be null");
return from(new StringReader(swaggerString));
}
/**
* Creates a OpenAPI2MarkupConverter.Builder from a given Swagger YAML or JSON reader.
*
* @param schemaReader the schema YAML or JSON reader.
* @return a OpenAPI2MarkupConverter
*/
public static Builder from(Reader schemaReader) {
Validate.notNull(schemaReader, "swaggerReader must not be null");
OpenAPI openAPI;
try {
//TODO
openAPI = new OpenAPIV3Parser().read(IOUtils.toString(schemaReader));
} catch (IOException e) {
throw new RuntimeException("Swagger source can not be parsed", e);
}
if (openAPI == null)
throw new IllegalArgumentException("Swagger source is in a wrong format");
return new Builder(openAPI);
}
@Override
public void toFolder(Path outputDirectory) {
Validate.notNull(outputDirectory, "outputDirectory must not be null");
openAPIContext.setOutputPath(outputDirectory);
writeToFile(applyOverviewDocument(), outputDirectory.resolve(openAPIContext.config.getOverviewDocument()));
writeToFile(applyPathsDocument(), outputDirectory.resolve(openAPIContext.config.getPathsDocument()));
writeToFile(applyComponentsDocument(), outputDirectory.resolve(openAPIContext.config.getDefinitionsDocument()));
writeToFile(applySecurityDocument(), outputDirectory.resolve(openAPIContext.config.getSecurityDocument()));
}
@Override
public void toFile(Path outputFile) {
Validate.notNull(outputFile, "outputFile must not be null");
writeToFile(applyOverviewDocument(), outputFile);
writeToFile(applyPathsDocument(), outputFile);
writeToFile(applyComponentsDocument(), outputFile);
writeToFile(applySecurityDocument(), outputFile);
}
@Override
public void toFileWithoutExtension(Path outputFile) {
Validate.notNull(outputFile, "outputFile must not be null");
writeToFileWithoutExtension(applyOverviewDocument(), outputFile);
writeToFileWithoutExtension(applyPathsDocument(), outputFile);
writeToFileWithoutExtension(applyComponentsDocument(), outputFile);
writeToFileWithoutExtension(applySecurityDocument(), outputFile);
}
@Override
public String toString() {
return applyOverviewDocument().convert() +
applyPathsDocument().convert() +
applyComponentsDocument().convert() +
applySecurityDocument().convert();
}
private Document applyOverviewDocument() {
return overviewDocument.apply(
openAPIContext.createDocument(),
OverviewDocument.parameters(openAPIContext.getSchema()));
}
private Document applyPathsDocument() {
return pathsDocument.apply(
openAPIContext.createDocument(),
PathsDocument.parameters(openAPIContext.getSchema()));
}
private Document applyComponentsDocument() {
return componentsDocument.apply(
openAPIContext.createDocument(),
ComponentsDocument.parameters(openAPIContext.getSchema().getComponents()));
}
private Document applySecurityDocument() {
return securityDocument.apply(
openAPIContext.createDocument(),
SecurityDocument.parameters(openAPIContext.getSchema()));
}
private void writeToFile(Document document, Path path) {
MarkupLanguage markupLanguage = openAPIContext.config.getMarkupLanguage();
if (isMarkupLanguageSupported(markupLanguage)) {
String fileExtension = markupLanguage.getFileNameExtensions().get(0);
writeToFileWithoutExtension(document, path.resolveSibling(path.getFileName().toString() + fileExtension));
} else {
throw new RuntimeException("Given Markup language '"+markupLanguage+"' is not supported by "+getClass().getName());
}
}
private boolean isMarkupLanguageSupported(MarkupLanguage markupLanguage) {
return markupLanguage == MarkupLanguage.ASCIIDOC;
}
private void writeToFileWithoutExtension(Document document, Path file) {
if (file.getParent() != null) {
try {
Files.createDirectories(file.getParent());
} catch (IOException e) {
throw new RuntimeException("Failed create directory", e);
}
}
try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) {
writer.write(document.convert());
} catch (IOException e) {
throw new RuntimeException("Failed to write file", e);
}
if (logger.isInfoEnabled()) {
logger.info("Markup document written to: {}", file);
}
}
public static class OpenAPIContext extends Context<OpenAPI> {
private OpenSchema2MarkupConfig config;
private OpenAPI2MarkupExtensionRegistry extensionRegistry;
public OpenAPIContext(OpenSchema2MarkupConfig config,
OpenAPI2MarkupExtensionRegistry extensionRegistry,
OpenAPI schema, URI swaggerLocation, Labels labels) {
super(config, extensionRegistry, schema, swaggerLocation, labels);
this.config = config;
this.extensionRegistry = extensionRegistry;
}
@Override
public OpenSchema2MarkupConfig getConfig() {
return config;
}
@Override
public OpenAPI2MarkupExtensionRegistry getExtensionRegistry() {
return extensionRegistry;
}
public Document createDocument() {
return new DocumentImpl();
}
}
public static class Builder {
private final OpenAPI openAPI;
private final URI schemaLocation;
private OpenSchema2MarkupConfig config;
private OpenAPI2MarkupExtensionRegistry extensionRegistry;
/**
* Creates a Builder from a remote URL.
*
* @param schemaUrl the remote URL
*/
Builder(URL schemaUrl) {
try {
this.schemaLocation = schemaUrl.toURI();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("swaggerURL is in a wrong format", e);
}
this.openAPI = readSchema(schemaUrl.toString());
}
/**
* Creates a Builder from a local Path.
*
* @param swaggerPath the local Path
*/
Builder(Path swaggerPath) {
this.schemaLocation = swaggerPath.toAbsolutePath().toUri();
this.openAPI = readSchema(swaggerPath.toString());
}
/**
* Creates a Builder using a given Swagger model.
*
* @param openAPI the Swagger source.
*/
Builder(OpenAPI openAPI) {
this.openAPI = openAPI;
this.schemaLocation = null;
}
/**
* Uses the SwaggerParser to read the Swagger source.
*
* @param schemaLocation the location of the Swagger source
* @return the Swagger model
*/
private OpenAPI readSchema(String schemaLocation) {
OpenAPI openAPI = new OpenAPIV3Parser().read(schemaLocation);
if (openAPI == null) {
throw new IllegalArgumentException("Failed to read the schema");
}
return openAPI;
}
public Builder withConfig(OpenSchema2MarkupConfig config) {
Validate.notNull(config, "config must not be null");
this.config = config;
return this;
}
public Builder withExtensionRegistry(OpenAPI2MarkupExtensionRegistry registry) {
Validate.notNull(registry, "registry must not be null");
this.extensionRegistry = registry;
return this;
}
public OpenAPI2MarkupConverter build() {
if (config == null)
config = new OpenAPI2MarkupConfigBuilder().build();
if (extensionRegistry == null)
extensionRegistry = new OpenAPI2MarkupExtensionRegistryBuilder().build();
OpenAPILabels openApiLabels = new OpenAPILabels(config);
OpenAPIContext context = new OpenAPIContext(config, extensionRegistry, openAPI, schemaLocation, openApiLabels);
initExtensions(context);
applySwaggerExtensions(context);
return new OpenAPI2MarkupConverter(context);
}
private void initExtensions(OpenAPIContext context) {
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.setGlobalContext(context));
extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
extensionRegistry.getPathsDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
extensionRegistry.getSecurityDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
}
private void applySwaggerExtensions(OpenAPIContext context) {
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.apply(context.getSchema()));
}
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup;
import org.apache.commons.configuration2.Configuration;
import java.util.Map;
import java.util.Properties;
public class OpenAPI2MarkupProperties extends Schema2MarkupProperties {
public OpenAPI2MarkupProperties(Properties properties) {
super(properties);
}
public OpenAPI2MarkupProperties(Map<String, String> map) {
super(map);
}
public OpenAPI2MarkupProperties(Configuration configuration) {
super(configuration);
}
}

View File

@@ -1,7 +0,0 @@
package io.github.swagger2markup;
import io.github.swagger2markup.config.builder.Schema2MarkupConfigBuilder;
public class OpenSchema2MarkupConfig extends Schema2MarkupConfigBuilder.DefaultSchema2MarkupConfig {
}

View File

@@ -1,72 +0,0 @@
package io.github.swagger2markup.config;
import io.github.swagger2markup.Labels;
import io.github.swagger2markup.OpenSchema2MarkupConfig;
import java.util.ResourceBundle;
public class OpenAPILabels extends Labels {
public static final String LABEL_CONTENT = "label_content";
public static final String LABEL_DEFAULT = "label_default";
public static final String LABEL_DEPRECATED = "label_deprecated";
public static final String LABEL_EXAMPLE = "label_example";
public static final String LABEL_EXAMPLES = "label_examples";
public static final String LABEL_EXCLUSIVE_MAXIMUM = "label_exclusive_maximum";
public static final String LABEL_EXCLUSIVE_MINIMUM = "label_exclusive_minimum";
public static final String LABEL_EXTERNAL_VALUE = "label_external_value";
public static final String LABEL_FORMAT = "label_format";
public static final String LABEL_MAXIMUM = "label_maximum";
public static final String LABEL_MAX_ITEMS = "label_max_items";
public static final String LABEL_MAX_LENGTH = "label_max_length";
public static final String LABEL_MAX_PROPERTIES = "label_max_properties";
public static final String LABEL_MINIMUM = "label_minimum";
public static final String LABEL_MIN_ITEMS = "label_min_items";
public static final String LABEL_MIN_LENGTH = "label_min_length";
public static final String LABEL_MIN_PROPERTIES = "label_min_properties";
public static final String LABEL_MULTIPLE_OF = "label_multiple_of";
public static final String LABEL_NO_LINKS = "label_no_links";
public static final String LABEL_NULLABLE = "label_nullable";
public static final String LABEL_OPERATION = "label_operation";
public static final String LABEL_OPTIONAL = "label_optional";
public static final String LABEL_PARAMETERS = "label_parameters";
public static final String LABEL_READ_ONLY = "label_read_only";
public static final String LABEL_REQUIRED = "label_required";
public static final String LABEL_SERVER = "label_server";
public static final String LABEL_TERMS_OF_SERVICE = "label_terms_of_service";
public static final String LABEL_TITLE = "label_title";
public static final String LABEL_TYPE = "label_type";
public static final String LABEL_UNIQUE_ITEMS = "label_unique_items";
public static final String LABEL_WRITE_ONLY = "label_write_only";
public static final String SECTION_TITLE_COMPONENTS = "section_title_components";
public static final String SECTION_TITLE_PARAMETERS = "section_title_parameters";
public static final String SECTION_TITLE_PATHS = "section_title_paths";
public static final String SECTION_TITLE_SCHEMAS = "section_title_schemas";
public static final String SECTION_TITLE_SECURITY = "section_title_security";
public static final String SECTION_TITLE_SERVERS = "section_title_servers";
public static final String SECTION_TITLE_OVERVIEW = "section_title_overview";
public static final String SECTION_TITLE_TAGS = "section_title_tags";
public static final String SECTION_TITLE_RESPONSES = "section_title_responses";
public static final String SECTION_TITLE_HEADERS = "section_title_headers";
public static final String SECTION_TITLE_LINKS = "section_title_links";
public static final String TABLE_HEADER_DEFAULT = "table_header_default";
public static final String TABLE_HEADER_DESCRIPTION = "table_header_description";
public static final String TABLE_HEADER_HTTP_CODE = "table_header_http_code";
public static final String TABLE_HEADER_LINKS = "table_header_links";
public static final String TABLE_HEADER_NAME = "table_header_name";
public static final String TABLE_HEADER_POSSIBLE_VALUES = "table_header_possible_values";
public static final String TABLE_HEADER_SCHEMA = "table_header_schema";
public static final String TABLE_HEADER_SCOPES = "table_header_scopes";
public static final String TABLE_HEADER_TYPE = "table_header_type";
public static final String TABLE_HEADER_VARIABLE = "table_header_variable";
public static final String TABLE_TITLE_HEADERS = "table_title_headers";
public static final String TABLE_TITLE_PARAMETERS = "table_title_parameters";
public static final String TABLE_TITLE_PROPERTIES = "table_title_properties";
public static final String TABLE_TITLE_RESPONSES = "table_title_responses";
public static final String TABLE_TITLE_SECURITY = "table_title_security";
public static final String TABLE_TITLE_SERVER_VARIABLES = "table_title_server_variables";
public OpenAPILabels(OpenSchema2MarkupConfig config) {
super(ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getLanguage().toLocale()));
}
}

View File

@@ -1,38 +0,0 @@
package io.github.swagger2markup.config.builder;
import io.github.swagger2markup.OpenAPI2MarkupProperties;
import io.github.swagger2markup.OpenSchema2MarkupConfig;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.ConfigurationConverter;
import org.apache.commons.configuration2.MapConfiguration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import java.util.Map;
import java.util.Properties;
public class OpenAPI2MarkupConfigBuilder extends Schema2MarkupConfigBuilder<OpenAPI2MarkupConfigBuilder, OpenSchema2MarkupConfig> {
public OpenAPI2MarkupConfigBuilder() {
this(new PropertiesConfiguration());
}
public OpenAPI2MarkupConfigBuilder(Properties properties) {
this(ConfigurationConverter.getConfiguration(properties));
}
public OpenAPI2MarkupConfigBuilder(Map<String, String> map) {
this(new MapConfiguration(map));
}
private OpenAPI2MarkupConfigBuilder(Configuration configuration) {
super(OpenAPI2MarkupConfigBuilder.class,
new OpenSchema2MarkupConfig(),
new OpenAPI2MarkupProperties(getCompositeConfiguration(configuration)), configuration);
}
@Override
public OpenSchema2MarkupConfig build() {
buildNaturalOrdering();
return config;
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import io.github.swagger2markup.OpenAPI2MarkupConverter.OpenAPIContext;
/**
* An abstract OpenAPI extension which must be extended by an other OpenAPI extensions
*/
abstract class AbstractExtension implements Extension {
protected OpenAPIContext globalContext;
/**
* Global context lazy initialization
*
* @param globalContext Global context
*/
public void setGlobalContext(OpenAPIContext globalContext) {
this.globalContext = globalContext;
}
}

View File

@@ -1,15 +0,0 @@
package io.github.swagger2markup.extension;
import org.asciidoctor.ast.Document;
public class ContentContext {
private Document document;
public ContentContext(Document document) {
this.document = document;
}
public Document getDocument() {
return document;
}
}

View File

@@ -1,94 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import io.swagger.models.Model;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import java.util.Optional;
/**
* DefinitionsDocumentExtension extension point can be used to extend the definitions document content.
*/
public abstract class DefinitionsDocumentExtension extends AbstractExtension {
public abstract void apply(Context context);
public enum Position {
DOCUMENT_BEFORE,
DOCUMENT_BEGIN,
DOCUMENT_END,
DOCUMENT_AFTER,
DEFINITION_BEFORE,
DEFINITION_BEGIN,
DEFINITION_END,
DEFINITION_AFTER
}
public static class Context extends ContentContext {
private Position position;
/**
* null if position == DOCUMENT_*
*/
private String definitionName;
/**
* null if position == DOCUMENT_*
*/
private Model model;
/**
* @param position the current position
* @param document document object
*/
public Context(Position position, Document document) {
super(document);
Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position);
this.position = position;
}
/**
* @param position the current position
* @param document document object
* @param definitionName the name of the current definition
* @param model the current Model of the definition
*/
public Context(Position position, Document document, String definitionName, Model model) {
super(document);
Validate.inclusiveBetween(Position.DEFINITION_BEFORE, Position.DEFINITION_AFTER, position);
Validate.notNull(definitionName);
Validate.notNull(model);
this.position = position;
this.definitionName = definitionName;
this.model = model;
}
public Position getPosition() {
return position;
}
public Optional<String> getDefinitionName() {
return Optional.ofNullable(definitionName);
}
public Optional<Model> getModel() {
return Optional.ofNullable(model);
}
}
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import static io.github.swagger2markup.OpenAPI2MarkupConverter.OpenAPIContext;
/**
* Extension interface which must be implemented by an OpenAPI extension
*/
interface Extension {
/**
* Global context lazy initialization
*
* @param globalContext Global context
*/
void setGlobalContext(OpenAPIContext globalContext);
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import io.github.swagger2markup.OpenSchema2MarkupConfig;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.Labels;
import io.swagger.v3.oas.models.OpenAPI;
import io.vavr.Function2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class MarkupComponent<D, T, R> implements Function2<D, T, R> {
protected Logger logger = LoggerFactory.getLogger(getClass());
protected OpenAPI2MarkupConverter.Context<OpenAPI> context;
protected Labels labels;
protected OpenSchema2MarkupConfig config;
protected OpenAPI2MarkupExtensionRegistry extensionRegistry;
public MarkupComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
this.context = context;
this.config = context.getConfig();
this.extensionRegistry = context.getExtensionRegistry();
this.labels = context.getLabels();
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import java.util.List;
/**
* Extension points registry interface.
*/
public interface OpenAPI2MarkupExtensionRegistry extends Schema2MarkupExtensionRegistry {
/**
* OpenAPIModelExtension extension point can be used to preprocess the Swagger model.
*
* @return registered extensions extending OpenAPIModelExtension extension point
*/
List<OpenAPIModelExtension> getSwaggerModelExtensions();
/**
* OverviewDocumentExtension extension point can be used to extend the overview document content.
*
* @return registered extensions extending OverviewDocumentExtension extension point
*/
List<OverviewDocumentExtension> getOverviewDocumentExtensions();
/**
* DefinitionsDocumentExtension extension point can be used to extend the definitions document content.
*
* @return registered extensions extending DefinitionsDocumentExtension extension point
*/
List<DefinitionsDocumentExtension> getDefinitionsDocumentExtensions();
/**
* SecurityContentExtension extension point can be used to extend the security document content.
*
* @return registered extensions extending SecurityContentExtension extension point
*/
List<SecurityDocumentExtension> getSecurityDocumentExtensions();
/**
* PathsDocumentExtension extension point can be used to extend the paths document content.
*
* @return registered extensions extending PathsDocumentExtension extension point
*/
List<PathsDocumentExtension> getPathsDocumentExtensions();
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import io.swagger.v3.oas.models.OpenAPI;
/**
* OpenAPIModelExtension extension point can be used to preprocess the Swagger model.
*/
public abstract class OpenAPIModelExtension extends AbstractExtension {
public abstract void apply(OpenAPI openAPI);
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import org.asciidoctor.ast.Document;
/**
* OverviewDocumentExtension extension point can be used to extend the overview document content.
*/
public abstract class OverviewDocumentExtension extends AbstractExtension {
public abstract void apply(Context context);
public enum Position {
DOCUMENT_BEFORE,
DOCUMENT_AFTER,
DOCUMENT_BEGIN,
DOCUMENT_END
}
public static class Context extends ContentContext {
private Position position;
/**
* @param position the current position
* @param document document object
*/
public Context(Position position, Document document) {
super(document);
this.position = position;
}
public Position getPosition() {
return position;
}
}
}

View File

@@ -1,101 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import io.github.swagger2markup.model.PathOperation;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import java.util.Optional;
/**
* PathsDocumentExtension extension point can be used to extend the paths document content.
*/
public abstract class PathsDocumentExtension extends AbstractExtension {
public abstract void apply(Context context);
public enum Position {
DOCUMENT_BEFORE,
DOCUMENT_BEGIN,
DOCUMENT_END,
DOCUMENT_AFTER,
OPERATION_BEFORE,
OPERATION_BEGIN,
OPERATION_END,
OPERATION_AFTER,
OPERATION_DESCRIPTION_BEFORE,
OPERATION_DESCRIPTION_BEGIN,
OPERATION_DESCRIPTION_END,
OPERATION_DESCRIPTION_AFTER,
OPERATION_PARAMETERS_BEFORE,
OPERATION_PARAMETERS_BEGIN,
OPERATION_PARAMETERS_END,
OPERATION_PARAMETERS_AFTER,
OPERATION_RESPONSES_BEFORE,
OPERATION_RESPONSES_BEGIN,
OPERATION_RESPONSES_END,
OPERATION_RESPONSES_AFTER,
OPERATION_SECURITY_BEFORE,
OPERATION_SECURITY_BEGIN,
OPERATION_SECURITY_END,
OPERATION_SECURITY_AFTER
}
public static class Context extends ContentContext {
private Position position;
/**
* null if position == DOCUMENT_*
*/
private PathOperation operation;
/**
* Context for positions DOCUMENT_*
*
* @param position the current position
* @param document document object
*/
public Context(Position position, Document document) {
super(document);
Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position);
this.position = position;
}
/**
* Context for all other positions
*
* @param position the current position
* @param document document object
* @param operation the current path operation
*/
public Context(Position position, Document document, PathOperation operation) {
super(document);
Validate.inclusiveBetween(Position.OPERATION_BEFORE, Position.OPERATION_SECURITY_AFTER, position);
Validate.notNull(operation);
this.position = position;
this.operation = operation;
}
public Position getPosition() {
return position;
}
public Optional<PathOperation> getOperation() {
return Optional.ofNullable(operation);
}
}
}

View File

@@ -1,94 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension;
import io.swagger.models.auth.SecuritySchemeDefinition;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import java.util.Optional;
/**
* SecurityContentExtension extension point can be used to extend the security document content.
*/
public abstract class SecurityDocumentExtension extends AbstractExtension {
public abstract void apply(Context context);
public enum Position {
DOCUMENT_BEFORE,
DOCUMENT_BEGIN,
DOCUMENT_END,
DOCUMENT_AFTER,
SECURITY_SCHEME_BEFORE,
SECURITY_SCHEME_BEGIN,
SECURITY_SCHEME_END,
SECURITY_SCHEME_AFTER
}
public static class Context extends ContentContext {
private Position position;
/**
* null if position == DOCUMENT_*
*/
private String securitySchemeName;
/**
* null if position == DOCUMENT_*
*/
private SecuritySchemeDefinition securityScheme;
/**
* @param position the current position
* @param document the MarkupDocBuilder
*/
public Context(Position position, Document document) {
super(document);
Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position);
this.position = position;
}
/**
* @param position the current position
* @param document the MarkupDocBuilder
* @param securitySchemeName the name of the current securityScheme
* @param securityScheme the current security scheme securityScheme
*/
public Context(Position position, Document document, String securitySchemeName, SecuritySchemeDefinition securityScheme) {
super(document);
Validate.inclusiveBetween(Position.SECURITY_SCHEME_BEFORE, Position.SECURITY_SCHEME_AFTER, position);
Validate.notNull(securitySchemeName);
Validate.notNull(securityScheme);
this.position = position;
this.securitySchemeName = securitySchemeName;
this.securityScheme = securityScheme;
}
public Position getPosition() {
return position;
}
public Optional<String> getSecuritySchemeName() {
return Optional.ofNullable(securitySchemeName);
}
public Optional<SecuritySchemeDefinition> getSecurityScheme() {
return Optional.ofNullable(securityScheme);
}
}
}

View File

@@ -1,127 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.extension.builder;
import io.github.swagger2markup.extension.*;
import java.util.List;
import static java.util.ServiceLoader.load;
import static org.apache.commons.collections4.IteratorUtils.toList;
public class OpenAPI2MarkupExtensionRegistryBuilder {
private final Context context;
public OpenAPI2MarkupExtensionRegistryBuilder() {
List<OpenAPIModelExtension> openAPIModelExtensions = toList(load(OpenAPIModelExtension.class).iterator());
List<OverviewDocumentExtension> overviewDocumentExtensions = toList(load(OverviewDocumentExtension.class).iterator());
List<DefinitionsDocumentExtension> definitionsDocumentExtensions = toList(load(DefinitionsDocumentExtension.class).iterator());
List<PathsDocumentExtension> pathsDocumentExtensions = toList(load(PathsDocumentExtension.class).iterator());
List<SecurityDocumentExtension> securityDocumentExtensions = toList(load(SecurityDocumentExtension.class).iterator());
context = new Context(
openAPIModelExtensions,
overviewDocumentExtensions,
definitionsDocumentExtensions,
pathsDocumentExtensions,
securityDocumentExtensions);
}
public OpenAPI2MarkupExtensionRegistry build() {
return new DefaultOpenAPI2MarkupExtensionRegistry(context);
}
public OpenAPI2MarkupExtensionRegistryBuilder withSwaggerModelExtension(OpenAPIModelExtension extension) {
context.openAPIModelExtensions.add(extension);
return this;
}
public OpenAPI2MarkupExtensionRegistryBuilder withOverviewDocumentExtension(OverviewDocumentExtension extension) {
context.overviewDocumentExtensions.add(extension);
return this;
}
public OpenAPI2MarkupExtensionRegistryBuilder withDefinitionsDocumentExtension(DefinitionsDocumentExtension extension) {
context.definitionsDocumentExtensions.add(extension);
return this;
}
public OpenAPI2MarkupExtensionRegistryBuilder withPathsDocumentExtension(PathsDocumentExtension extension) {
context.pathsDocumentExtensions.add(extension);
return this;
}
public OpenAPI2MarkupExtensionRegistryBuilder withSecurityDocumentExtension(SecurityDocumentExtension extension) {
context.securityDocumentExtensions.add(extension);
return this;
}
static class DefaultOpenAPI2MarkupExtensionRegistry implements OpenAPI2MarkupExtensionRegistry {
private Context context;
DefaultOpenAPI2MarkupExtensionRegistry(Context context) {
this.context = context;
}
@Override
public List<OpenAPIModelExtension> getSwaggerModelExtensions() {
return context.openAPIModelExtensions;
}
@Override
public List<OverviewDocumentExtension> getOverviewDocumentExtensions() {
return context.overviewDocumentExtensions;
}
@Override
public List<DefinitionsDocumentExtension> getDefinitionsDocumentExtensions() {
return context.definitionsDocumentExtensions;
}
@Override
public List<SecurityDocumentExtension> getSecurityDocumentExtensions() {
return context.securityDocumentExtensions;
}
@Override
public List<PathsDocumentExtension> getPathsDocumentExtensions() {
return context.pathsDocumentExtensions;
}
}
private static class Context {
final List<OpenAPIModelExtension> openAPIModelExtensions;
final List<OverviewDocumentExtension> overviewDocumentExtensions;
final List<DefinitionsDocumentExtension> definitionsDocumentExtensions;
final List<PathsDocumentExtension> pathsDocumentExtensions;
final List<SecurityDocumentExtension> securityDocumentExtensions;
Context(List<OpenAPIModelExtension> openAPIModelExtensions,
List<OverviewDocumentExtension> overviewDocumentExtensions,
List<DefinitionsDocumentExtension> definitionsDocumentExtensions,
List<PathsDocumentExtension> pathsDocumentExtensions,
List<SecurityDocumentExtension> securityDocumentExtensions) {
this.openAPIModelExtensions = openAPIModelExtensions;
this.overviewDocumentExtensions = overviewDocumentExtensions;
this.definitionsDocumentExtensions = definitionsDocumentExtensions;
this.pathsDocumentExtensions = pathsDocumentExtensions;
this.securityDocumentExtensions = securityDocumentExtensions;
}
}
}

View File

@@ -1,101 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.media.Encoding;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.StructuralNode;
import java.util.Collections;
import java.util.Map;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXAMPLES;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.italicUnconstrained;
public class EncodingComponent extends MarkupComponent<StructuralNode, EncodingComponent.Parameters, StructuralNode> {
private final HeadersComponent headersComponent;
public EncodingComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.headersComponent = new HeadersComponent(context);
}
public static EncodingComponent.Parameters parameters(Map<String, Encoding> encodings) {
return new EncodingComponent.Parameters(encodings);
}
public StructuralNode apply(StructuralNode node, Map<String, Encoding> encodings) {
return apply(node, parameters(encodings));
}
@Override
public StructuralNode apply(StructuralNode node, EncodingComponent.Parameters parameters) {
Map<String, Encoding> encodings = parameters.encodings;
if (encodings == null || encodings.isEmpty()) return node;
DescriptionListImpl encodingList = new DescriptionListImpl(node);
encodingList.setTitle(labels.getLabel(LABEL_EXAMPLES));
encodings.forEach((name, encoding) -> {
DescriptionListEntryImpl encodingEntry = new DescriptionListEntryImpl(encodingList, Collections.singletonList(new ListItemImpl(encodingList, name)));
ListItemImpl tagDesc = new ListItemImpl(encodingEntry, "");
ParagraphBlockImpl encodingBlock = new ParagraphBlockImpl(tagDesc);
StringBuilder sb = new StringBuilder();
String contentType = encoding.getContentType();
if(StringUtils.isNotBlank(contentType)){
sb.append("Content-Type:").append(contentType).append(LINE_SEPARATOR);
}
if(encoding.getAllowReserved()){
sb.append(italicUnconstrained("Allow Reserved").toLowerCase()).append(LINE_SEPARATOR);
}
if(encoding.getExplode()){
sb.append(italicUnconstrained("Explode").toLowerCase()).append(LINE_SEPARATOR);
}
Encoding.StyleEnum style = encoding.getStyle();
if(style != null){
sb.append("style").append(style).append(LINE_SEPARATOR);
}
encodingBlock.setSource(sb.toString());
tagDesc.append(encodingBlock);
headersComponent.apply(tagDesc, encoding.getHeaders());
encodingEntry.setDescription(tagDesc);
encodingList.addEntry(encodingEntry);
});
node.append(encodingList);
return node;
}
public static class Parameters {
private final Map<String, Encoding> encodings;
public Parameters(Map<String, Encoding> encodings) {
this.encodings = encodings;
}
}
}

View File

@@ -1,108 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.examples.Example;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.StructuralNode;
import java.util.Collections;
import java.util.Map;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXAMPLES;
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXTERNAL_VALUE;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.appendDescription;
public class ExamplesComponent extends MarkupComponent<StructuralNode, ExamplesComponent.Parameters, StructuralNode> {
private final MediaTypeExampleComponent mediaTypeExampleComponent;
public ExamplesComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.mediaTypeExampleComponent = new MediaTypeExampleComponent(context);
}
public static ExamplesComponent.Parameters parameters(Map<String, Example> examples) {
return new ExamplesComponent.Parameters(examples);
}
public StructuralNode apply(StructuralNode node, Map<String, Example> examples) {
return apply(node, parameters(examples));
}
@Override
public StructuralNode apply(StructuralNode node, ExamplesComponent.Parameters parameters) {
Map<String, Example> examples = parameters.examples;
if (examples == null || examples.isEmpty()) return node;
DescriptionListImpl examplesList = new DescriptionListImpl(node);
examplesList.setTitle(labels.getLabel(LABEL_EXAMPLES));
examples.forEach((name, example) -> {
DescriptionListEntryImpl exampleEntry = new DescriptionListEntryImpl(examplesList, Collections.singletonList(new ListItemImpl(examplesList, name)));
ListItemImpl tagDesc = new ListItemImpl(exampleEntry, "");
ParagraphBlockImpl exampleBlock = new ParagraphBlockImpl(tagDesc);
appendDescription(exampleBlock, example.getSummary());
appendDescription(exampleBlock, example.getDescription());
mediaTypeExampleComponent.apply(tagDesc, example.getValue());
ParagraphBlockImpl paragraphBlock = new ParagraphBlockImpl(tagDesc);
String source = "";
generateRefLink(source, example.getExternalValue(), labels.getLabel(LABEL_EXTERNAL_VALUE));
generateRefLink(source, example.get$ref(), "");
if(StringUtils.isNotBlank(source)){
paragraphBlock.setSource(source);
tagDesc.append(paragraphBlock);
}
exampleEntry.setDescription(tagDesc);
examplesList.addEntry(exampleEntry);
});
node.append(examplesList);
return node;
}
private String generateRefLink(String source, String ref, String alt) {
if (StringUtils.isNotBlank(ref)) {
if (StringUtils.isBlank(alt)) {
alt = ref.substring(ref.lastIndexOf('/') + 1);
}
String anchor = ref.replaceFirst("#", "").replaceAll("/", "_");
source += "<<" + anchor + "," + alt + ">>" + LINE_SEPARATOR;
}
return source;
}
public static class Parameters {
private final Map<String, Example> examples;
public Parameters(Map<String, Example> examples) {
this.examples = examples;
}
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.extension.MarkupComponent;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.swagger.v3.oas.models.ExternalDocumentation;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.Block;
import org.asciidoctor.ast.StructuralNode;
public class ExternalDocumentationComponent extends MarkupComponent<StructuralNode, ExternalDocumentationComponent.Parameters, StructuralNode> {
public ExternalDocumentationComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
}
public static Parameters parameters(ExternalDocumentation externalDocs) {
return new Parameters(externalDocs);
}
public StructuralNode apply(StructuralNode node, ExternalDocumentation externalDocs) {
return apply(node, parameters(externalDocs));
}
@Override
public StructuralNode apply(StructuralNode node, Parameters params) {
ExternalDocumentation externalDocs = params.externalDocs;
if (externalDocs == null) return node;
String url = externalDocs.getUrl();
if (StringUtils.isNotBlank(url)) {
Block paragraph = new ParagraphBlockImpl(node);
String desc = externalDocs.getDescription();
paragraph.setSource(url + (StringUtils.isNotBlank(desc) ? "[" + desc + "]" : ""));
node.append(paragraph);
}
return node;
}
public static class Parameters {
private final ExternalDocumentation externalDocs;
public Parameters(ExternalDocumentation externalDocs) {
this.externalDocs = externalDocs;
}
}
}

View File

@@ -1,79 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.headers.Header;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.generateInnerDoc;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.getSchemaTypeAsString;
public class HeadersComponent extends MarkupComponent<StructuralNode, HeadersComponent.Parameters, StructuralNode> {
private final SchemaComponent schemaComponent;
public HeadersComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.schemaComponent = new SchemaComponent(context);
}
public static HeadersComponent.Parameters parameters(Map<String, Header> headers) {
return new HeadersComponent.Parameters(headers);
}
public StructuralNode apply(StructuralNode node, Map<String, Header> headers) {
return apply(node, parameters(headers));
}
@Override
public StructuralNode apply(StructuralNode node, HeadersComponent.Parameters parameters) {
Map<String, Header> headers = parameters.headers;
if (null == headers || headers.isEmpty()) return node;
TableImpl responseHeadersTable = new TableImpl(node, new HashMap<>(), new ArrayList<>());
responseHeadersTable.setOption("header");
responseHeadersTable.setAttribute("caption", "", true);
responseHeadersTable.setAttribute("cols", ".^2a,.^14a,.^4a", true);
responseHeadersTable.setTitle(labels.getLabel(TABLE_TITLE_HEADERS));
responseHeadersTable.setHeaderRow(labels.getLabel(TABLE_HEADER_NAME), labels.getLabel(TABLE_HEADER_DESCRIPTION), labels.getLabel(TABLE_HEADER_SCHEMA));
headers.forEach((name, header) ->
responseHeadersTable.addRow(
generateInnerDoc(responseHeadersTable, name),
generateInnerDoc(responseHeadersTable, Optional.ofNullable(header.getDescription()).orElse("")),
generateInnerDoc(responseHeadersTable, getSchemaTypeAsString(header.getSchema()))
));
node.append(responseHeadersTable);
return node;
}
public static class Parameters {
private final Map<String, Header> headers;
public Parameters(Map<String, Header> headers) {
this.headers = headers;
}
}
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.links.Link;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import java.util.Map;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.italicUnconstrained;
public class LinkComponent extends MarkupComponent<StructuralNode, LinkComponent.Parameters, StructuralNode> {
public LinkComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
}
public static LinkComponent.Parameters parameters(Map<String, Link> links) {
return new LinkComponent.Parameters(links);
}
public Document apply(StructuralNode parent, Map<String, Link> links) {
return apply(parent, parameters(links));
}
@Override
public Document apply(StructuralNode parent, LinkComponent.Parameters parameters) {
DocumentImpl linksDocument = new DocumentImpl(parent);
ParagraphBlockImpl linkParagraph = new ParagraphBlockImpl(linksDocument);
Map<String, Link> links = parameters.links;
if (null == links || links.isEmpty()) {
linkParagraph.setSource(labels.getLabel(LABEL_NO_LINKS));
} else {
StringBuilder sb = new StringBuilder();
links.forEach((name, link) -> {
sb.append(name).append(" +").append(LINE_SEPARATOR);
sb.append(italicUnconstrained(labels.getLabel(LABEL_OPERATION))).append(' ')
.append(italicUnconstrained(link.getOperationId())).append(" +").append(LINE_SEPARATOR);
Map<String, String> linkParameters = link.getParameters();
if (null != linkParameters && !linkParameters.isEmpty()) {
sb.append(italicUnconstrained(labels.getLabel(LABEL_PARAMETERS))).append(" {").append(" +").append(LINE_SEPARATOR);
linkParameters.forEach((param, value) ->
sb.append('"').append(param).append("\": \"").append(value).append('"').append(" +").append(LINE_SEPARATOR)
);
sb.append('}').append(" +").append(LINE_SEPARATOR);
}
});
linkParagraph.setSource(sb.toString());
}
linksDocument.append(linkParagraph);
return linksDocument;
}
public static class Parameters {
private final Map<String, Link> links;
public Parameters(Map<String, Link> links) {
this.links = links;
}
}
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.media.Content;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import java.util.Collections;
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_CONTENT;
public class MediaContentComponent extends MarkupComponent<StructuralNode, MediaContentComponent.Parameters, StructuralNode> {
private final MediaTypeExampleComponent mediaTypeExampleComponent;
private final ExamplesComponent examplesComponent;
private final SchemaComponent schemaComponent;
private final EncodingComponent encodingComponent;
public MediaContentComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.mediaTypeExampleComponent = new MediaTypeExampleComponent(context);
this.examplesComponent = new ExamplesComponent(context);
this.schemaComponent = new SchemaComponent(context);
this.encodingComponent = new EncodingComponent(context);
}
public static MediaContentComponent.Parameters parameters(Content content) {
return new MediaContentComponent.Parameters(content);
}
public StructuralNode apply(StructuralNode node, Content content) {
return apply(node, parameters(content));
}
@Override
public StructuralNode apply(StructuralNode node, MediaContentComponent.Parameters parameters) {
Content content = parameters.content;
if (content == null || content.isEmpty()) return node;
DescriptionListImpl mediaContentList = new DescriptionListImpl(node);
mediaContentList.setTitle(labels.getLabel(LABEL_CONTENT));
content.forEach((type, mediaType) -> {
DescriptionListEntryImpl tagEntry = new DescriptionListEntryImpl(mediaContentList, Collections.singletonList(new ListItemImpl(mediaContentList, type)));
ListItemImpl tagDesc = new ListItemImpl(tagEntry, "");
Document tagDescDocument = schemaComponent.apply(mediaContentList, mediaType.getSchema());
mediaTypeExampleComponent.apply(tagDescDocument, mediaType.getExample());
examplesComponent.apply(tagDescDocument, mediaType.getExamples());
encodingComponent.apply(tagDescDocument, mediaType.getEncoding());
tagDesc.append(tagDescDocument);
tagEntry.setDescription(tagDesc);
mediaContentList.addEntry(tagEntry);
});
node.append(mediaContentList);
return node;
}
public static class Parameters {
private final Content content;
public Parameters(Content content) {
this.content = content;
}
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.StructuralNode;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.DELIMITER_BLOCK;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXAMPLE;
public class MediaTypeExampleComponent extends MarkupComponent<StructuralNode, MediaTypeExampleComponent.Parameters, StructuralNode> {
public MediaTypeExampleComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
}
public static MediaTypeExampleComponent.Parameters parameters(Object example) {
return new MediaTypeExampleComponent.Parameters(example);
}
public StructuralNode apply(StructuralNode node, Object example) {
return apply(node, parameters(example));
}
@Override
public StructuralNode apply(StructuralNode node, MediaTypeExampleComponent.Parameters parameters) {
Object example = parameters.example;
if (example == null || StringUtils.isBlank(example.toString())) return node;
ParagraphBlockImpl sourceBlock = new ParagraphBlockImpl(node);
sourceBlock.setTitle(labels.getLabel(LABEL_EXAMPLE));
sourceBlock.setAttribute("style", "source", true);
sourceBlock.setSource(DELIMITER_BLOCK + LINE_SEPARATOR + example + LINE_SEPARATOR + DELIMITER_BLOCK);
node.append(sourceBlock);
return node;
}
public static class Parameters {
private final Object example;
public Parameters(Object example) {
this.example = example;
}
}
}

View File

@@ -1,103 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.ast.Table;
import java.util.*;
import java.util.stream.Collectors;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
public class ParametersComponent extends MarkupComponent<StructuralNode, ParametersComponent.Parameters, StructuralNode> {
private final SchemaComponent schemaComponent;
public ParametersComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.schemaComponent = new SchemaComponent(context);
}
public static ParametersComponent.Parameters parameters(Map<String, Parameter> parameters) {
return new ParametersComponent.Parameters(parameters);
}
public static ParametersComponent.Parameters parameters(List<Parameter> parameters) {
if(null == parameters) {
return new ParametersComponent.Parameters(new HashMap<>());
}
return new ParametersComponent.Parameters(parameters.stream().collect(Collectors.toMap(Parameter::getName, parameter -> parameter)));
}
public StructuralNode apply(StructuralNode parent, List<Parameter> params) {
return apply(parent, parameters(params));
}
public StructuralNode apply(StructuralNode parent, Map<String, Parameter> params) {
return apply(parent, parameters(params));
}
@Override
public StructuralNode apply(StructuralNode parent, ParametersComponent.Parameters componentParameters) {
Map<String, Parameter> parameters = componentParameters.parameters;
if (null == parameters || parameters.isEmpty()) return parent;
TableImpl pathParametersTable = new TableImpl(parent, new HashMap<>(), new ArrayList<>());
pathParametersTable.setOption("header");
pathParametersTable.setAttribute("caption", "", true);
pathParametersTable.setAttribute("cols", ".^2a,.^3a,.^10a,.^5a", true);
pathParametersTable.setTitle(labels.getLabel(TABLE_TITLE_PARAMETERS));
pathParametersTable.setHeaderRow(
labels.getLabel(TABLE_HEADER_TYPE),
labels.getLabel(TABLE_HEADER_NAME),
labels.getLabel(TABLE_HEADER_DESCRIPTION),
labels.getLabel(TABLE_HEADER_SCHEMA));
parameters.forEach((alt, parameter) ->
pathParametersTable.addRow(
generateInnerDoc(pathParametersTable, boldUnconstrained(parameter.getIn()), alt),
getParameterNameDocument(pathParametersTable, parameter),
generateInnerDoc(pathParametersTable, Optional.ofNullable(parameter.getDescription()).orElse("")),
generateInnerDoc(pathParametersTable, getSchemaTypeAsString(parameter.getSchema()))
));
parent.append(pathParametersTable);
return parent;
}
private Document getParameterNameDocument(Table table, Parameter parameter) {
String documentContent = boldUnconstrained(parameter.getName()) + " +" + LINE_SEPARATOR + requiredIndicator(parameter.getRequired(),
labels.getLabel(LABEL_REQUIRED), labels.getLabel(LABEL_OPTIONAL));
return generateInnerDoc(table, documentContent);
}
public static class Parameters {
private final Map<String, Parameter> parameters;
public Parameters(Map<String, Parameter> parameters) {
this.parameters = parameters;
}
}
}

View File

@@ -1,89 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.media.Schema;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
public class PropertiesTableComponent extends MarkupComponent<StructuralNode, PropertiesTableComponent.Parameters, StructuralNode> {
private final SchemaComponent schemaComponent;
PropertiesTableComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.schemaComponent = new SchemaComponent(context);
}
public static Parameters parameters(@SuppressWarnings("rawtypes") Map<String, Schema> properties, List<String> schemaRequired) {
return new Parameters(properties, schemaRequired);
}
public StructuralNode apply(StructuralNode parent, @SuppressWarnings("rawtypes") Map<String, Schema> properties, List<String> schemaRequired) {
return apply(parent, parameters(properties, schemaRequired));
}
public StructuralNode apply(StructuralNode parent, Parameters params) {
@SuppressWarnings("rawtypes") Map<String, Schema> properties = params.properties;
List<String> schemaRequired = params.schemaRequired;
if (null == properties || properties.isEmpty()) return parent;
List<String> finalSchemaRequired = (null == schemaRequired) ? new ArrayList<>() : schemaRequired;
TableImpl propertiesTable = new TableImpl(parent, new HashMap<>(), new ArrayList<>());
propertiesTable.setOption("header");
propertiesTable.setAttribute("caption", "", true);
propertiesTable.setAttribute("cols", ".^4a,.^16a,.^4a", true);
propertiesTable.setTitle(labels.getLabel(TABLE_TITLE_PROPERTIES));
propertiesTable.setHeaderRow(
labels.getLabel(TABLE_HEADER_NAME),
labels.getLabel(TABLE_HEADER_DESCRIPTION),
labels.getLabel(TABLE_HEADER_SCHEMA));
properties.forEach((name, schema) -> propertiesTable.addRow(
generateInnerDoc(propertiesTable, name + LINE_SEPARATOR + requiredIndicator(finalSchemaRequired.contains(name),
labels.getLabel(LABEL_REQUIRED), labels.getLabel(LABEL_OPTIONAL))),
schemaComponent.apply(propertiesTable, schema),
generateInnerDoc(propertiesTable, getSchemaTypeAsString(schema))
));
parent.append(propertiesTable);
return parent;
}
@SuppressWarnings("rawtypes")
public static class Parameters {
private final Map<String, Schema> properties;
private final List<String> schemaRequired;
public Parameters(Map<String, Schema> properties, List<String> schemaRequired) {
this.properties = properties;
this.schemaRequired = schemaRequired;
}
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.ast.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.generateInnerDoc;
public class ResponseComponent extends MarkupComponent<StructuralNode, ResponseComponent.Parameters, StructuralNode> {
private final HeadersComponent headersComponent;
private final LinkComponent linkComponent;
private final MediaContentComponent mediaContentComponent;
public ResponseComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.headersComponent = new HeadersComponent(context);
this.linkComponent = new LinkComponent(context);
this.mediaContentComponent = new MediaContentComponent(context);
}
public static Parameters parameters(Map<String, ApiResponse> apiResponses) {
return new Parameters(apiResponses);
}
public StructuralNode apply(StructuralNode serverSection, Map<String, ApiResponse> apiResponses) {
return apply(serverSection, parameters(apiResponses));
}
@Override
public StructuralNode apply(StructuralNode serverSection, Parameters params) {
Map<String, ApiResponse> apiResponses = params.apiResponses;
if (null == apiResponses || apiResponses.isEmpty()) return serverSection;
TableImpl pathResponsesTable = new TableImpl(serverSection, new HashMap<>(), new ArrayList<>());
pathResponsesTable.setOption("header");
pathResponsesTable.setAttribute("caption", "", true);
pathResponsesTable.setAttribute("cols", ".^2a,.^14a,.^4a", true);
pathResponsesTable.setTitle(labels.getLabel(TABLE_TITLE_RESPONSES));
pathResponsesTable.setHeaderRow(
labels.getLabel(TABLE_HEADER_HTTP_CODE),
labels.getLabel(TABLE_HEADER_DESCRIPTION),
labels.getLabel(TABLE_HEADER_LINKS));
apiResponses.forEach((httpCode, apiResponse) ->
pathResponsesTable.addRow(
generateInnerDoc(pathResponsesTable, httpCode),
getResponseDescriptionColumnDocument(pathResponsesTable, apiResponse),
linkComponent.apply(pathResponsesTable, apiResponse.getLinks())
));
serverSection.append(pathResponsesTable);
return serverSection;
}
private Document getResponseDescriptionColumnDocument(Table table, ApiResponse apiResponse) {
Document document = generateInnerDoc(table, Optional.ofNullable(apiResponse.getDescription()).orElse(""));
headersComponent.apply(document, apiResponse.getHeaders());
mediaContentComponent.apply(document, apiResponse.getContent());
return document;
}
public static class Parameters {
private final Map<String, ApiResponse> apiResponses;
public Parameters(Map<String, ApiResponse> apiResponses) {
this.apiResponses = apiResponses;
}
}
}

View File

@@ -1,118 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.github.swagger2markup.internal.helper.OpenApiHelpers;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.boldUnconstrained;
public class SchemaComponent extends MarkupComponent<StructuralNode, SchemaComponent.Parameters, StructuralNode> {
private final OpenAPI2MarkupConverter.OpenAPIContext context;
public SchemaComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.context = context;
}
public static SchemaComponent.Parameters parameters(@SuppressWarnings("rawtypes") Schema schema) {
return new SchemaComponent.Parameters(schema);
}
public Document apply(StructuralNode parent, @SuppressWarnings("rawtypes") Schema schema) {
return apply(parent, parameters(schema));
}
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public Document apply(StructuralNode parent, SchemaComponent.Parameters parameters) {
Document schemaDocument = new DocumentImpl(parent);
Schema schema = parameters.schema;
if (null == schema) return schemaDocument;
OpenApiHelpers.appendDescription(schemaDocument, schema.getDescription());
Map<String, Boolean> schemasBooleanProperties = new HashMap<String, Boolean>() {{
put(labels.getLabel(LABEL_DEPRECATED), schema.getDeprecated());
put(labels.getLabel(LABEL_NULLABLE), schema.getNullable());
put(labels.getLabel(LABEL_READ_ONLY), schema.getReadOnly());
put(labels.getLabel(LABEL_WRITE_ONLY), schema.getWriteOnly());
put(labels.getLabel(LABEL_UNIQUE_ITEMS), schema.getUniqueItems());
put(labels.getLabel(LABEL_EXCLUSIVE_MAXIMUM), schema.getExclusiveMaximum());
put(labels.getLabel(LABEL_EXCLUSIVE_MINIMUM), schema.getExclusiveMinimum());
}};
Map<String, Object> schemasValueProperties = new HashMap<String, Object>() {{
put(labels.getLabel(LABEL_TITLE), schema.getTitle());
put(labels.getLabel(LABEL_DEFAULT), schema.getDefault());
put(labels.getLabel(LABEL_MAXIMUM), schema.getMaximum());
put(labels.getLabel(LABEL_MINIMUM), schema.getMinimum());
put(labels.getLabel(LABEL_MAX_LENGTH), schema.getMaxLength());
put(labels.getLabel(LABEL_MIN_LENGTH), schema.getMinLength());
put(labels.getLabel(LABEL_MAX_ITEMS), schema.getMaxItems());
put(labels.getLabel(LABEL_MIN_ITEMS), schema.getMinItems());
put(labels.getLabel(LABEL_MAX_PROPERTIES), schema.getMaxProperties());
put(labels.getLabel(LABEL_MIN_PROPERTIES), schema.getMinProperties());
put(labels.getLabel(LABEL_MULTIPLE_OF), schema.getMultipleOf());
}};
Stream<String> schemaBooleanStream = schemasBooleanProperties.entrySet().stream()
.filter(e -> null != e.getValue() && e.getValue())
.map(e -> OpenApiHelpers.italicUnconstrained(e.getKey().toLowerCase()));
Stream<String> schemaValueStream = schemasValueProperties.entrySet().stream()
.filter(e -> null != e.getValue() && StringUtils.isNotBlank(e.getValue().toString()))
.map(e -> boldUnconstrained(e.getKey()) + ": " + e.getValue());
ParagraphBlockImpl paragraphBlock = new ParagraphBlockImpl(schemaDocument);
String source = Stream.concat(schemaBooleanStream, schemaValueStream).collect(Collectors.joining(" +" + LINE_SEPARATOR));
paragraphBlock.setSource(source);
schemaDocument.append(paragraphBlock);
Map<String, Schema> properties = schema.getProperties();
if (null != properties && !properties.isEmpty()) {
PropertiesTableComponent propertiesTableComponent = new PropertiesTableComponent(context);
propertiesTableComponent.apply(schemaDocument, properties, schema.getRequired());
}
return schemaDocument;
}
@SuppressWarnings("rawtypes")
public static class Parameters {
private final Schema schema;
public Parameters(Schema schema) {
this.schema = schema;
}
}
}

View File

@@ -1,86 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
public class SecurityRequirementTableComponent extends MarkupComponent<StructuralNode, SecurityRequirementTableComponent.Parameters, StructuralNode> {
public SecurityRequirementTableComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
}
public static SecurityRequirementTableComponent.Parameters parameters(List<SecurityRequirement> securityRequirements, boolean addTitle) {
return new SecurityRequirementTableComponent.Parameters(securityRequirements, addTitle);
}
public StructuralNode apply(StructuralNode document, List<SecurityRequirement> securityRequirements, boolean addTitle) {
return apply(document, parameters(securityRequirements, addTitle));
}
@Override
public StructuralNode apply(StructuralNode node, SecurityRequirementTableComponent.Parameters parameters) {
List<SecurityRequirement> securityRequirements = parameters.securityRequirements;
if (securityRequirements == null || securityRequirements.isEmpty()) return node;
TableImpl securityRequirementsTable = new TableImpl(node, new HashMap<>(), new ArrayList<>());
securityRequirementsTable.setOption("header");
securityRequirementsTable.setAttribute("caption", "", true);
securityRequirementsTable.setAttribute("cols", ".^3a,.^4a,.^13a", true);
if (parameters.addTitle) {
securityRequirementsTable.setTitle(labels.getLabel(TABLE_TITLE_SECURITY));
}
securityRequirementsTable.setHeaderRow(
labels.getLabel(TABLE_HEADER_TYPE),
labels.getLabel(TABLE_HEADER_NAME),
labels.getLabel(TABLE_HEADER_SCOPES));
securityRequirements.forEach(securityRequirement ->
securityRequirement.forEach((name, scopes) ->
securityRequirementsTable.addRow(
generateInnerDoc(securityRequirementsTable, boldUnconstrained(scopes.isEmpty() ? "apiKey" : "oauth2")),
generateInnerDoc(securityRequirementsTable, name),
generateInnerDoc(securityRequirementsTable, String.join(", ", scopes))
)
)
);
node.append(securityRequirementsTable);
return node;
}
public static class Parameters {
private final List<SecurityRequirement> securityRequirements;
private final boolean addTitle;
public Parameters(List<SecurityRequirement> securityRequirements, boolean addTitle) {
this.securityRequirements = securityRequirements;
this.addTitle = addTitle;
}
}
}

View File

@@ -1,86 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.swagger.v3.oas.models.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Section;
import java.util.Collections;
import java.util.List;
import static io.github.swagger2markup.config.OpenAPILabels.SECTION_TITLE_TAGS;
public class TagsComponent extends MarkupComponent<Document, TagsComponent.Parameters, Document> {
private final ExternalDocumentationComponent externalDocumentationComponent;
public TagsComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.externalDocumentationComponent = new ExternalDocumentationComponent(context);
}
public static TagsComponent.Parameters parameters(List<Tag> tags) {
return new TagsComponent.Parameters(tags);
}
public Document apply(Document document, List<Tag> tags) {
return apply(document, parameters(tags));
}
@Override
public Document apply(Document document, TagsComponent.Parameters parameters) {
List<Tag> openAPITags = parameters.tags;
if (null == openAPITags || openAPITags.isEmpty()) return document;
Section tagsSection = new SectionImpl(document);
tagsSection.setTitle(labels.getLabel(SECTION_TITLE_TAGS));
DescriptionListImpl tagsList = new DescriptionListImpl(tagsSection);
openAPITags.forEach(tag -> {
DescriptionListEntryImpl tagEntry = new DescriptionListEntryImpl(tagsList, Collections.singletonList(new ListItemImpl(tagsList, tag.getName())));
String description = tag.getDescription();
if(StringUtils.isNotBlank(description)){
ListItemImpl tagDesc = new ListItemImpl(tagEntry, "");
tagDesc.setSource(description);
externalDocumentationComponent.apply(tagDesc, tag.getExternalDocs());
tagEntry.setDescription(tagDesc);
}
tagsList.addEntry(tagEntry);
});
tagsSection.append(tagsList);
document.append(tagsSection);
return document;
}
public static class Parameters {
private final List<Tag> tags;
public Parameters(List<Tag> tags) {
this.tags = tags;
}
}
}

View File

@@ -1,122 +0,0 @@
package io.github.swagger2markup.internal.document;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.github.swagger2markup.internal.component.*;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.headers.Header;
import io.swagger.v3.oas.models.links.Link;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Section;
import org.asciidoctor.ast.StructuralNode;
import java.util.Map;
import static io.github.swagger2markup.config.OpenAPILabels.*;
public class ComponentsDocument extends MarkupComponent<Document, ComponentsDocument.Parameters, Document> {
private final ParametersComponent parametersComponent;
private final ResponseComponent responseComponent;
private final HeadersComponent headersComponent;
private final SchemaComponent schemaComponent;
private final LinkComponent linkComponent;
public ComponentsDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.parametersComponent = new ParametersComponent(context);
this.responseComponent = new ResponseComponent(context);
this.headersComponent = new HeadersComponent(context);
this.schemaComponent = new SchemaComponent(context);
this.linkComponent = new LinkComponent(context);
}
public static Parameters parameters(Components components) {
return new Parameters(components);
}
@Override
public Document apply(Document document, ComponentsDocument.Parameters parameters) {
appendComponentsSection(document, parameters.components);
return document;
}
public static class Parameters {
private final Components components;
public Parameters(Components components) {
this.components = Validate.notNull(components, "Schema must not be null");
}
}
private void appendComponentsSection(Document document, Components components) {
if (null == components) return;
Section componentsSection = new SectionImpl(document);
componentsSection.setTitle(labels.getLabel(SECTION_TITLE_COMPONENTS));
String componentSectionId = "_components";
componentsSection.setId(componentSectionId);
appendComponentsSchemasSection(componentsSection, componentSectionId, components.getSchemas());
Map<String, Parameter> parameters = components.getParameters();
if (null != parameters && !parameters.isEmpty()) {
appendSubSection(componentsSection, componentSectionId, parametersComponent, SECTION_TITLE_PARAMETERS,
new ParametersComponent.Parameters(parameters));
}
Map<String, ApiResponse> responses = components.getResponses();
if (null != responses && !responses.isEmpty()) {
appendSubSection(componentsSection, componentSectionId, responseComponent, SECTION_TITLE_RESPONSES,
new ResponseComponent.Parameters(responses));
}
Map<String, Header> headers = components.getHeaders();
if (null != headers && !headers.isEmpty()) {
appendSubSection(componentsSection, componentSectionId, headersComponent, SECTION_TITLE_HEADERS,
new HeadersComponent.Parameters(headers));
}
Map<String, Link> links = components.getLinks();
if (null != links && !links.isEmpty()) {
appendSubSection(componentsSection, componentSectionId, linkComponent, SECTION_TITLE_LINKS,
new LinkComponent.Parameters(links));
}
document.append(componentsSection);
}
private void appendComponentsSchemasSection(
Section componentsSection, String componentSectionId,
@SuppressWarnings("rawtypes") Map<String, Schema> schemas) {
if (null == schemas || schemas.isEmpty()) return;
SectionImpl schemasSection = new SectionImpl(componentsSection);
String schemasSectionId = componentSectionId + "_schemas";
schemasSection.setTitle(labels.getLabel(SECTION_TITLE_SCHEMAS));
schemasSection.setId(schemasSectionId);
schemas.forEach((name, schema) -> {
String schemaDocumentId = schemasSectionId + "_" + name;
Document schemaDocument = schemaComponent.apply(schemasSection, schema);
schemaDocument.setTitle(name);
schemaDocument.setId(schemaDocumentId);
schemasSection.append(schemaDocument);
});
componentsSection.append(schemasSection);
}
private <T> void appendSubSection(Section componentsSection, String componentSectionId,
MarkupComponent<StructuralNode, T, StructuralNode> markupComponent,
String sectionLabel, T parameters) {
SectionImpl parametersSection = new SectionImpl(componentsSection);
String parametersSectionId = componentSectionId + "_parameters";
parametersSection.setTitle(labels.getLabel(sectionLabel));
parametersSection.setId(parametersSectionId);
markupComponent.apply(parametersSection, parameters);
componentsSection.append(parametersSection);
}
}

View File

@@ -1,138 +0,0 @@
package io.github.swagger2markup.internal.document;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.BlockImpl;
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.github.swagger2markup.extension.OverviewDocumentExtension;
import io.github.swagger2markup.internal.component.ExternalDocumentationComponent;
import io.github.swagger2markup.internal.component.TagsComponent;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Block;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Section;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Optional;
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_TERMS_OF_SERVICE;
import static io.github.swagger2markup.config.OpenAPILabels.SECTION_TITLE_OVERVIEW;
import static io.github.swagger2markup.extension.OverviewDocumentExtension.Context;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.appendDescription;
public class OverviewDocument extends MarkupComponent<Document, OverviewDocument.Parameters, Document> {
private final TagsComponent tagsComponent;
private final ExternalDocumentationComponent externalDocumentationComponent;
public OverviewDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
tagsComponent = new TagsComponent(context);
this.externalDocumentationComponent = new ExternalDocumentationComponent(context);
}
public static OverviewDocument.Parameters parameters(OpenAPI schema) {
return new OverviewDocument.Parameters(schema);
}
@Override
public Document apply(Document document, Parameters parameters) {
Info apiInfo = parameters.openAPI.getInfo();
document.setAttribute("openapi", parameters.openAPI.getOpenapi(), true);
addDocumentTitle(document, apiInfo);
addAuthorInfo(document, apiInfo);
addVersionInfo(document, apiInfo);
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_BEFORE, document));
Document subDocument = new DocumentImpl(document);
Section overviewDoc = new SectionImpl(subDocument, "section", new HashMap<>(), new ArrayList<>(),
null, new ArrayList<>(), 1, "", new ArrayList<>(),
null, null, "", "", false, false);
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_BEGIN, subDocument));
overviewDoc.setTitle(labels.getLabel(SECTION_TITLE_OVERVIEW));
appendDescription(overviewDoc, apiInfo.getDescription());
appendTermsOfServiceInfo(overviewDoc, apiInfo);
appendLicenseInfo(overviewDoc, apiInfo);
subDocument.append(overviewDoc);
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_END, subDocument));
document.append(subDocument);
externalDocumentationComponent.apply(document, parameters.openAPI.getExternalDocs());
tagsComponent.apply(document, parameters.openAPI.getTags());
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_AFTER, document));
return document;
}
private void applyOverviewDocumentExtension(Context context) {
extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.apply(context));
}
private void addDocumentTitle(Document rootDocument, Info apiInfo) {
String title = apiInfo.getTitle();
if (StringUtils.isNotBlank(title)) {
rootDocument.setTitle(title);
}
}
private void addVersionInfo(Document rootDocument, Info info) {
String version = info.getVersion();
if (StringUtils.isNotBlank(version)) {
rootDocument.setAttribute("revnumber", version, true);
}
}
private void addAuthorInfo(Document rootDocument, Info info) {
Contact contact = info.getContact();
if (null != contact) {
String author = Optional.ofNullable(contact.getName()).orElse("");
String email = contact.getEmail();
if (StringUtils.isNotBlank(email)) {
rootDocument.setAttribute("email", email, true);
}
rootDocument.setAttribute("author", author, true);
rootDocument.setAttribute("authorcount", 1L, true);
}
}
private void appendLicenseInfo(Section overviewDoc, Info info) {
License license = info.getLicense();
if (null != license) {
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotBlank(license.getUrl())) {
sb.append(license.getUrl()).append("[");
}
sb.append(license.getName());
if (StringUtils.isNotBlank(license.getUrl())) {
sb.append("]");
}
BlockImpl paragraph = new ParagraphBlockImpl(overviewDoc);
paragraph.setSource(sb.toString());
overviewDoc.append(paragraph);
}
}
private void appendTermsOfServiceInfo(Section overviewDoc, Info info) {
String termsOfService = info.getTermsOfService();
if (StringUtils.isNotBlank(termsOfService)) {
Block paragraph = new ParagraphBlockImpl(overviewDoc);
paragraph.setSource(termsOfService + "[" + labels.getLabel(LABEL_TERMS_OF_SERVICE) + "]");
overviewDoc.append(paragraph);
}
}
public static class Parameters {
private final OpenAPI openAPI;
public Parameters(OpenAPI openAPI) {
this.openAPI = Validate.notNull(openAPI, "Schema must not be null");
}
}
}

View File

@@ -1,116 +0,0 @@
package io.github.swagger2markup.internal.document;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.github.swagger2markup.internal.component.ExternalDocumentationComponent;
import io.github.swagger2markup.internal.component.ParametersComponent;
import io.github.swagger2markup.internal.component.ResponseComponent;
import io.github.swagger2markup.internal.component.SecurityRequirementTableComponent;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Paths;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariables;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Section;
import org.asciidoctor.ast.StructuralNode;
import java.util.*;
import static io.github.swagger2markup.config.OpenAPILabels.*;
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
public class PathsDocument extends MarkupComponent<Document, PathsDocument.Parameters, Document> {
private final ParametersComponent parametersComponent;
private final ExternalDocumentationComponent externalDocumentationComponent;
private final ResponseComponent responseComponent;
private final SecurityRequirementTableComponent securityRequirementTableComponent;
public PathsDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.parametersComponent = new ParametersComponent(context);
this.externalDocumentationComponent = new ExternalDocumentationComponent(context);
this.responseComponent = new ResponseComponent(context);
this.securityRequirementTableComponent = new SecurityRequirementTableComponent(context);
}
public static Parameters parameters(OpenAPI schema) {
return new Parameters(schema);
}
@Override
public Document apply(Document document, Parameters parameters) {
Paths apiPaths = parameters.schema.getPaths();
if (null == apiPaths || apiPaths.isEmpty()) return document;
SectionImpl allPathsSection = new SectionImpl(document);
allPathsSection.setTitle(labels.getLabel(SECTION_TITLE_PATHS));
apiPaths.forEach((name, pathItem) ->
pathItem.readOperationsMap().forEach(((httpMethod, operation) -> {
SectionImpl operationSection = new SectionImpl(allPathsSection);
String summary = Optional.ofNullable(operation.getSummary()).orElse("");
operationSection.setTitle((italicUnconstrained(httpMethod.name().toUpperCase()) + " " + monospaced(name) + " " + summary).trim());
appendDescription(operationSection, operation.getDescription());
externalDocumentationComponent.apply(operationSection, operation.getExternalDocs());
parametersComponent.apply(operationSection, operation.getParameters());
responseComponent.apply(operationSection, operation.getResponses());
appendServersSection(operationSection, operation.getServers());
securityRequirementTableComponent.apply(operationSection, operation.getSecurity(), false);
allPathsSection.append(operationSection);
})));
document.append(allPathsSection);
return document;
}
private void appendServersSection(StructuralNode node, List<Server> servers) {
if (null == servers || servers.isEmpty()) return;
Section serversSection = new SectionImpl(node);
serversSection.setTitle(labels.getLabel(SECTION_TITLE_SERVERS));
servers.forEach(server -> {
Section serverSection = new SectionImpl(serversSection);
serverSection.setTitle(italicUnconstrained(labels.getLabel(LABEL_SERVER)) + ": " + server.getUrl());
appendDescription(serverSection, server.getDescription());
ServerVariables variables = server.getVariables();
appendVariables(serverSection, variables);
serversSection.append(serverSection);
});
node.append(serversSection);
}
private void appendVariables(Section serverSection, ServerVariables variables) {
if (null == variables || variables.isEmpty()) return;
TableImpl serverVariables = new TableImpl(serverSection, new HashMap<String, Object>() {{
put("header-option", "");
put("cols", ".^2a,.^9a,.^3a,.^4a");
}}, new ArrayList<>());
serverVariables.setTitle(labels.getLabel(TABLE_TITLE_SERVER_VARIABLES));
serverVariables.setHeaderRow(labels.getLabel(TABLE_HEADER_VARIABLE), labels.getLabel(TABLE_HEADER_DESCRIPTION),
labels.getLabel(TABLE_HEADER_POSSIBLE_VALUES), labels.getLabel(TABLE_HEADER_DEFAULT)
);
variables.forEach((name, variable) -> {
String possibleValues = String.join(", ", Optional.ofNullable(variable.getEnum()).orElse(Collections.singletonList("Any")));
serverVariables.addRow(name, Optional.ofNullable(variable.getDescription()).orElse(""), possibleValues, variable.getDefault());
});
serverSection.append(serverVariables);
}
public static class Parameters {
private final OpenAPI schema;
public Parameters(OpenAPI schema) {
this.schema = Validate.notNull(schema, "Schema must not be null");
}
}
}

View File

@@ -1,49 +0,0 @@
package io.github.swagger2markup.internal.document;
import io.github.swagger2markup.OpenAPI2MarkupConverter;
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
import io.github.swagger2markup.extension.MarkupComponent;
import io.github.swagger2markup.internal.component.SecurityRequirementTableComponent;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import org.apache.commons.lang3.Validate;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Section;
import java.util.List;
import static io.github.swagger2markup.config.OpenAPILabels.SECTION_TITLE_SECURITY;
public class SecurityDocument extends MarkupComponent<Document, SecurityDocument.Parameters, Document> {
private final SecurityRequirementTableComponent securityRequirementTableComponent;
public SecurityDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
super(context);
this.securityRequirementTableComponent = new SecurityRequirementTableComponent(context);
}
public static Parameters parameters(OpenAPI schema) {
return new Parameters(schema);
}
@Override
public Document apply(Document document, SecurityDocument.Parameters parameters) {
List<SecurityRequirement> securityRequirements = parameters.schema.getSecurity();
if (null == securityRequirements || securityRequirements.isEmpty()) return document;
Section securityRequirementsSection = new SectionImpl(document);
securityRequirementsSection.setTitle(labels.getLabel(SECTION_TITLE_SECURITY));
securityRequirementTableComponent.apply(securityRequirementsSection, securityRequirements, false);
document.append(securityRequirementsSection);
return document;
}
public static class Parameters {
private final OpenAPI schema;
public Parameters(OpenAPI schema) {
this.schema = Validate.notNull(schema, "Schema must not be null");
}
}
}

View File

@@ -1,115 +0,0 @@
package io.github.swagger2markup.internal.helper;
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.Block;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.ast.Table;
import java.util.List;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
public class OpenApiHelpers {
public static void appendDescription(StructuralNode node, String description) {
if (StringUtils.isNotBlank(description)) {
Block paragraph = new ParagraphBlockImpl(node);
paragraph.setSource(description);
node.append(paragraph);
}
}
public static Document generateInnerDoc(Table table, String documentContent) {
return generateInnerDoc(table, documentContent, "");
}
public static Document generateInnerDoc(Table table, String documentContent, String id) {
Document innerDoc = new DocumentImpl(table);
if (StringUtils.isNotBlank(id)) {
innerDoc.setId(id);
}
Block paragraph = new ParagraphBlockImpl(innerDoc);
paragraph.setSource(documentContent);
innerDoc.append(paragraph);
return innerDoc;
}
public static String requiredIndicator(boolean isRequired, String labelRequired, String labelOptional) {
return italicUnconstrained(isRequired ? labelRequired : labelOptional).toLowerCase();
}
public static String superScript(String str) {
return "^" + str + "^";
}
public static String subScript(String str) {
return "~" + str + "~";
}
public static String italicUnconstrained(String str) {
return "__" + str + "__";
}
public static String boldUnconstrained(String str) {
return "**" + str + "**";
}
public static String monospaced(String str) {
return "`" + str + "`";
}
public static String getSchemaTypeAsString(Schema schema) {
StringBuilder stringBuilder = new StringBuilder();
if (schema instanceof ArraySchema) {
stringBuilder.append("< ");
Schema<?> items = ((ArraySchema) schema).getItems();
stringBuilder.append(getSchemaType(items));
stringBuilder.append(" > ");
stringBuilder.append(schema.getType());
} else {
List enumList = schema.getEnum();
if (enumList != null) {
stringBuilder.append("enum (");
for (Object value : enumList) {
stringBuilder.append(value.toString());
stringBuilder.append(",");
}
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
stringBuilder.append(')');
} else {
stringBuilder.append(getSchemaType(schema));
String format = schema.getFormat();
if (format != null) {
stringBuilder.append(' ');
stringBuilder.append('(');
stringBuilder.append(format);
stringBuilder.append(')');
}
}
}
return stringBuilder.toString();
}
private static String getSchemaType(Schema<?> schema) {
String type = schema.getType();
if (StringUtils.isNotEmpty(type)) {
return type;
} else {
return generateRefLink(schema.get$ref());
}
}
private static String generateRefLink(String ref) {
if (StringUtils.isNotBlank(ref)) {
String anchor = ref.toLowerCase().replaceFirst("#", "").replaceAll("/", "_");
return "<<" + anchor + ">>" + LINE_SEPARATOR;
}
return "";
}
}

View File

@@ -1,43 +0,0 @@
swagger2markup.markupLanguage=ASCIIDOC
swagger2markup.swaggerMarkupLanguage=ASCIIDOC
swagger2markup.hostnameEnabled=false
swagger2markup.basePathPrefixEnabled=false
swagger2markup.operationExtensionsEnabled=false
swagger2markup.definitionExtensionsEnabled=false
swagger2markup.separatedDefinitionsEnabled=false
swagger2markup.separatedOperationsEnabled=false
swagger2markup.pathsGroupedBy=AS_IS
swagger2markup.outputLanguage=EN
swagger2markup.inlineSchemaEnabled=true
swagger2markup.interDocumentCrossReferencesEnabled=false
swagger2markup.flatBodyEnabled=false
swagger2markup.pathSecuritySectionEnabled=true
swagger2markup.overviewDocument=overview
swagger2markup.pathsDocument=paths
swagger2markup.definitionsDocument=definitions
swagger2markup.securityDocument=security
swagger2markup.separatedOperationsFolder=operations
swagger2markup.separatedDefinitionsFolder=definitions
swagger2markup.tagOrderBy=NATURAL
swagger2markup.operationOrderBy=NATURAL
swagger2markup.definitionOrderBy=NATURAL
swagger2markup.parameterOrderBy=NATURAL
swagger2markup.propertyOrderBy=NATURAL
swagger2markup.responseOrderBy=NATURAL
swagger2markup.listDelimiterEnabled=false
swagger2markup.listDelimiter=,
swagger2markup.asciidoc.pegdown.timeoutMillis=2000
swagger2markup.generatedExamplesEnabled=false
# basic, curl, invoke-webrequest
swagger2markup.requestExamplesFormat=basic
# default, bash, powershell, etc.
swagger2markup.requestExamplesSourceFormat=default
# hide, inherit or hostname
swagger2markup.requestExamplesHost=hide
# hide, inherit or schema (e.g. https, https, etc.)
swagger2markup.requestExamplesSchema=hide
swagger2markup.requestExamplesHideBasePath=true
swagger2markup.requestExamplesIncludeAllQueryParams=false
# single, commaSeparated, multiple, multiple[]
swagger2markup.requestExamplesQueryArrayStyle=single

View File

@@ -1,58 +0,0 @@
label_content=Content
label_default=Default
label_deprecated=Deprecated
label_example=Example
label_examples=Examples
label_exclusive_maximum=Exclusive Maximum
label_exclusive_minimum=Exclusive Minimum
label_external_value=External Value
label_format=Format
label_maximum=Maximum
label_max_items=Maximum Items
label_max_length=Maximum Length
label_max_properties=Maximum Properties
label_minimum=Minimum
label_min_items=Minimum Items
label_min_length=Minimum Length
label_min_properties=Minimum Properties
label_multiple_of=Multiple Of
label_no_links=No Links
label_nullable=Nullable
label_operation=Operation
label_optional=Optional
label_parameters=Parameters
label_read_only=Read Only
label_required=Required
label_server=Server
label_terms_of_service=Terms Of Service
label_title=Title
label_type=Type
label_unique_items=Unique Items
label_write_only=Write Only
section_title_components=Components
section_title_parameters=Parameters
section_title_paths=Paths
section_title_schemas=Schemas
section_title_security=Security
section_title_servers=Servers
section_title_overview=Overview
section_title_tags=Tags
section_title_responses=Responses
section_title_headers=Headers
section_title_links=Links
table_header_default=Default
table_header_description=Description
table_header_http_code=Code
table_header_links=Links
table_header_name=Name
table_header_possible_values=Possible Values
table_header_schema=Schema
table_header_scopes=Scopes
table_header_type=Type
table_header_variable=Variable
table_title_headers=Headers
table_title_parameters=Parameters
table_title_properties=Properties
table_title_responses=Responses
table_title_security=Security
table_title_server_variables=Server Variables

View File

@@ -1,74 +0,0 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup;
import io.github.swagger2markup.assertions.DiffUtils;
import org.apache.commons.io.FileUtils;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
public class AsciidocConverterTest {
private static final String[] EXPECTED_FILES = new String[]{"definitions.adoc", "overview.adoc", "paths.adoc", "security.adoc"};
private List<String> expectedFiles;
@Before
public void setUp() {
expectedFiles = new ArrayList<>(asList(EXPECTED_FILES));
}
@Test
public void testToString() throws URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
//When
String asciiDocAsString = OpenAPI2MarkupConverter.from(file).build()
.toString();
//Then
Assertions.assertThat(asciiDocAsString).isNotEmpty();
System.out.println(asciiDocAsString);
}
@Test
public void testToFolder() throws URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/to_folder");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
OpenAPI2MarkupConverter.from(file).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/to_folder").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testToFolder.html");
}
}

View File

@@ -1,49 +0,0 @@
package io.github.swagger2markup;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.OpenAPIV3Parser;
import io.swagger.v3.parser.core.models.ParseOptions;
import io.swagger.v3.parser.core.models.SwaggerParseResult;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Arrays;
import static org.junit.Assert.assertNotNull;
@RunWith(Parameterized.class)
public class OpenApi2AsciiDocTest {
final private String openApiFile;
final private String expectedAsciiDoc;
public OpenApi2AsciiDocTest(String openApiFile, String expectedAsciiDoc) throws IOException {
this.openApiFile = "./src/test/resources/open_api/" + openApiFile;
this.expectedAsciiDoc = IOUtils.toString(getClass().getResourceAsStream("/asciidoc/" + expectedAsciiDoc), StandardCharsets.UTF_8);
}
@Parameterized.Parameters(name = "Run {index}: open api={0}, asciidoc={1}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
{"simple.yaml", "simple.adoc"},
{"petstore.yaml", "petstore.adoc"}
});
}
@Test
public void converts_open_api_v3_to_asciidoc() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation(openApiFile, null, options);
OpenAPI swagger = result.getOpenAPI();
assertNotNull(swagger);
OpenAPI2MarkupConverter converter = OpenAPI2MarkupConverter.from(swagger).build();
converter.toFolder(Paths.get("build/test/asciidoc"));
}
}

View File

@@ -1,55 +0,0 @@
/*
*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package io.github.swagger2markup.assertions;
import io.github.robwin.diff.DiffAssertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class DiffUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(DiffUtils.class);
public static void assertThatAllFilesAreEqual(Path expectedDirectory, Path actualDirectory, String reportName) {
Path reportPath = Paths.get("build/diff-report/", reportName);
try {
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(expectedDirectory)) {
for (Path expectedFile : directoryStream) {
Path actualFile = actualDirectory.resolve(expectedFile.getFileName());
LOGGER.info("Diffing file '{}' with '{}'", actualFile, expectedFile);
DiffAssertions.assertThat(actualFile).isEqualTo(expectedFile, reportPath);
}
}
} catch (IOException e) {
throw new RuntimeException("Failed to assert that all files are equal", e);
}
}
public static void assertThatFileIsEqual(Path expectedFile, Path actualFile, String reportName) {
Path reportPath = Paths.get("build/diff-report/", reportName);
LOGGER.info("Diffing file '{}' with '{}'", actualFile, expectedFile);
DiffAssertions.assertThat(actualFile).isEqualTo(expectedFile, reportPath);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,276 +0,0 @@
= Simple Inventory API
<you@your-company.com>
v1.0.0
:revnumber: 1.0.0
:openapi: 3.0.0
:authorcount: 1
:email: you@your-company.com
== Overview
This is a simple API
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0]
== Tags
admins::
Secured Admin-only calls
developers::
Operations available to regular developers
== Servers
=== __Server__: /
== Paths
=== __GET__ `/inventory` searches inventory
By passing in the appropriate options, you can search for
available inventory in the system
.Parameters
[%header,caption=,cols=".^2a,.^3a,.^10a,.^5a"]
|===
<.<|Type
<.<|Name
<.<|Description
<.<|Schema
<.<|**query**
<.<|**searchString** +
__optional__
<.<|pass an optional search string for looking up inventory
<.<|type: string
<.<|**query**
<.<|**limit** +
__optional__
<.<|maximum number of records to return
<.<|minimum: 0 +
type: integer +
maximum: 50 +
format: int32
<.<|**query**
<.<|**skip** +
__optional__
<.<|number of records to skip for pagination
<.<|minimum: 0 +
type: integer +
format: int32
|===
.Responses
[%header,caption=,cols=".^2a,.^14a,.^4a"]
|===
<.<|Code
<.<|Description
<.<|Links
<.<|200
<.<|search results matching criteria
.Content
application/json::
+
type: array
<.<|No Links
<.<|400
<.<|bad input parameter
<.<|No Links
|===
=== __POST__ `/inventory` adds an inventory item
Adds an item to the system
.Responses
[%header,caption=,cols=".^2a,.^14a,.^4a"]
|===
<.<|Code
<.<|Description
<.<|Links
<.<|201
<.<|item created
<.<|No Links
<.<|400
<.<|invalid input, object invalid
<.<|No Links
<.<|409
<.<|an existing item already exists
<.<|No Links
|===
[[_components]]
== Components
[[_components_schemas]]
=== Schemas
[[_components_schemas_inventoryitem]]
==== InventoryItem
type: object
.Properties
[%header,caption=,cols=".^4a,.^16a"]
|===
<.<|Name
<.<|Schema
<.<|id
__required__
<.<|type: string +
format: uuid
<.<|name
__required__
<.<|type: string
<.<|releaseDate
__required__
<.<|type: string +
format: date-time
<.<|manufacturer
__required__
<.<|<<_components_schemas_Manufacturer,Manufacturer>>
|===
[[_components_schemas_manufacturer]]
==== Manufacturer
type: object
.Properties
[%header,caption=,cols=".^4a,.^16a"]
|===
<.<|Name
<.<|Schema
<.<|name
__required__
<.<|type: string
<.<|homePage
__optional__
<.<|type: string +
format: url
<.<|phone
__optional__
<.<|type: string
|===

View File

@@ -1,351 +0,0 @@
[[_components]]
== Components
[[_components_schemas]]
=== Schemas
[[_components_schemas_user]]
==== User
.Properties
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|===
<.<|Name
<.<|Description
<.<|Schema
<.<|id
__optional__
<.<|
<.<|integer (int64)
<.<|username
__optional__
<.<|
<.<|string
<.<|firstName
__optional__
<.<|
<.<|string
<.<|lastName
__optional__
<.<|
<.<|string
<.<|email
__optional__
<.<|
<.<|string
<.<|password
__optional__
<.<|
<.<|string
<.<|phone
__optional__
<.<|
<.<|string
<.<|userStatus
__optional__
<.<|User Status
<.<|integer (int32)
|===
[[_components_schemas_category]]
==== Category
.Properties
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|===
<.<|Name
<.<|Description
<.<|Schema
<.<|id
__optional__
<.<|
<.<|integer (int64)
<.<|name
__optional__
<.<|The name of the category
**Maximum Length**: 255 +
**Minimum Length**: 0 +
**Default**: DefaultCategory
<.<|string
|===
[[_components_schemas_pet]]
==== Pet
.Properties
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|===
<.<|Name
<.<|Description
<.<|Schema
<.<|id
__optional__
<.<|
<.<|integer (int64)
<.<|category
__optional__
<.<|
<.<|<<_components_schemas_category>>
<.<|name
__required__
<.<|
<.<|string
<.<|photoUrls
__required__
<.<|
<.<|< string > array
<.<|tags
__optional__
<.<|
<.<|< <<_components_schemas_tag>>
> array
<.<|status
__optional__
<.<|pet status in the store,
<.<|enum (Dead,Alive)
|===
[[_components_schemas_tag]]
==== Tag
.Properties
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|===
<.<|Name
<.<|Description
<.<|Schema
<.<|id
__optional__
<.<|
<.<|integer (int64)
<.<|name
__optional__
<.<|
<.<|string
|===
[[_components_schemas_order]]
==== Order
.Properties
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|===
<.<|Name
<.<|Description
<.<|Schema
<.<|id
__optional__
<.<|
<.<|integer (int64)
<.<|petId
__optional__
<.<|
<.<|integer (int64)
<.<|quantity
__optional__
<.<|**Maximum**: 10000 +
**Minimum**: 0 +
**Default**: 0
<.<|integer (int32)
<.<|shipDate
__optional__
<.<|
<.<|string (date-time)
<.<|status
__optional__
<.<|Order Status
<.<|enum (Ordered,Cancelled)
<.<|complete
__optional__
<.<|
<.<|boolean
|===
[[_components_parameters]]
=== Responses
.Responses
[%header,caption=,cols=".^2a,.^14a,.^4a"]
|===
<.<|Code
<.<|Description
<.<|Links
<.<|InvalidId
<.<|Invalid ID supplied
<.<|No Links
|===

View File

@@ -1,30 +0,0 @@
= Swagger Petstore
apiteam@swagger.io
v1.0.0
:revnumber: 1.0.0
:openapi: 3.0.0
:author: apiteam@swagger.io
:authorcount: 1
== Overview
This is a sample server Petstore server.
[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.
For this sample, you can use the api key `special-key` to test the authorization filters
http://helloreverb.com/terms/[Terms Of Service]
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0]
http://swagger.io[Find out more about Swagger]
== Tags
pet::
Pet resource
store::
Store resource
user::
User resource

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="io.github.swagger2markup" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

View File

@@ -1,732 +0,0 @@
openapi: 3.0.0
servers:
- url: 'http://localhost:8000/v2/api'
info:
description: >-
This is a sample server Petstore server. You can find out more about
Swagger at http://swagger.io or on
irc.freenode.net, #swagger. For this sample, you can use the api key
"special-key" to test the authorization filters
version: 1.0.0
title: Swagger Petstore
termsOfService: 'http://swagger.io/terms/'
contact:
name: apiteam@swagger.io
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
externalDocs:
description: Find more info here
url: 'https://swagger.io'
tags:
- name: pet
description: Pet Operations
externalDocs:
url: 'http://swagger.io'
- name: user
description: All about the Users
paths:
/pet/add:
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: createPet
responses:
'200':
description: This is a sample
content:
text/plain:
schema:
type: string
example: 'whoa!'
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
/pet:
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: addPet
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
put:
tags:
- pet
summary: Update an existing pet
description: ''
operationId: updatePet
responses:
'400':
description: Invalid ID supplied
'404':
description: Pet not found
'405':
description: Validation exception
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
$ref: '#/components/requestBodies/Pet'
/pet/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma seperated strings
operationId: findPetsByStatus
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: false
style: pipeDelimited
schema:
type: array
items:
type: string
default: available
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/PetArray'
application/xml:
schema:
$ref: '#/components/schemas/PetArray'
'400':
description: Invalid status value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
/pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
description: >-
Muliple tags can be provided with comma seperated strings. Use tag1,
tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- name: tags
in: query
description: Tags to filter by
required: false
explode: true
schema:
type: array
items:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid tag value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
'/pet/{petId}':
get:
tags:
- pet
summary: Find pet by ID
description: >-
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
error conditions
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet that needs to be fetched
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
security:
- api_key: []
- petstore_auth:
- 'write:pets'
- 'read:pets'
post:
tags:
- pet
summary: Updates a pet in the store with form data
description: ''
operationId: updatePetWithForm
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
schema:
type: string
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string
delete:
tags:
- pet
summary: Deletes a pet
description: ''
operationId: deletePet
parameters:
- name: api_key
in: header
description: ''
required: false
schema:
type: string
- name: petId
in: path
description: Pet id to delete
required: true
schema:
type: integer
format: int64
responses:
'400':
description: Invalid pet value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: Pet extra params that needs to be deleted
'/pet/{petId}/uploadImage':
post:
tags:
- pet
summary: uploads an image
description: ''
operationId: uploadFile
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/ApiResponse"
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
/store/inventory:
get:
tags:
- store
summary: Returns pet inventories by status
description: Returns a map of status codes to quantities
operationId: get inventory+1
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: object
additionalProperties:
type: integer
format: int32
application/xml:
schema:
type: object
additionalProperties:
type: integer
format: int32
security:
- api_key: []
/store/order:
post:
tags:
- store
summary: Place an order for a pet
description: ''
operationId: placeOrder
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
application/xml:
schema:
$ref: '#/components/schemas/Order'
'400':
description: Invalid Order
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
description: order placed for purchasing the pet
'/store/order/{orderId}':
get:
tags:
- store
summary: Find purchase order by ID
description: >-
For valid response try integer IDs with value <= 5 or > 10. Other values
will generated exceptions
operationId: getOrderById
parameters:
- name: orderId
in: path
description: ID of pet that needs to be fetched
required: true
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
application/xml:
schema:
$ref: '#/components/schemas/Order'
'400':
description: Invalid ID supplied
'404':
description: Order not found
delete:
tags:
- store
summary: Delete purchase order by ID
description: >-
For valid response try integer IDs with value < 1000. Anything above
1000 or nonintegers will generate API errors
operationId: deleteOrder
parameters:
- name: orderId
in: path
description: ID of the order that needs to be deleted
required: true
schema:
type: string
responses:
'400':
description: Invalid ID supplied
'404':
description: Order not found
/user:
post:
tags:
- user
summary: Create user
description: This can only be done by the logged in user.
operationId: createUser
responses:
200:
content:
'application/json':
schema:
type: object
properties:
id:
# default is text/plain
type: string
format: text
examples:
foo:
value: {"foo": "bar"}
bar:
summary: A bar example
value: {"bar": "baz"}
default:
description: successful operation
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: Created user object
/user/createWithArray:
post:
tags:
- user
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithArrayInput
responses:
default:
description: successful operation
requestBody:
$ref: '#/components/requestBodies/UserArray'
/user/createWithList:
post:
tags:
- user
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithListInput
responses:
default:
description: successful operation
requestBody:
$ref: '#/components/requestBodies/UserArray'
/user/login:
get:
tags:
- user
security:
- https
summary: Logs user into the system
description: ''
operationId: loginUser
parameters:
- name: username
in: query
description: The user name for login
required: false
schema:
type: string
- name: password
in: query
description: The password for login in clear text
required: false
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: string
application/xml:
schema:
type: string
'400':
description: Invalid username/password supplied
/user/logout:
get:
tags:
- user
security:
- https
summary: Logs out current logged in user session
description: ''
operationId: logoutUser
responses:
default:
description: successful operation
'/user/{username}':
get:
tags:
- user
summary: Get user by user name
description: ''
operationId: getUserByName
parameters:
- name: username
in: path
description: 'The name that needs to be fetched. Use user1 for testing.'
required: true
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/User'
application/xml:
schema:
$ref: '#/components/schemas/User'
'400':
description: Invalid username supplied
'404':
description: User not found
put:
tags:
- user
summary: Updated user
description: This can only be done by the logged in user.
operationId: updateUser
parameters:
- name: username
in: path
description: name that need to be deleted
required: true
schema:
type: string
responses:
'400':
description: Invalid user supplied
'404':
description: User not found
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: Updated user object
delete:
tags:
- user
summary: Delete user
description: This can only be done by the logged in user.
operationId: deleteUser
parameters:
- name: username
in: path
description: The name that needs to be deleted
required: true
schema:
type: string
responses:
'400':
description: Invalid username supplied
'404':
description: User not found
security:
- foo:
- bar
- baz
a:
- b
- c
components:
parameters:
sharedSkip:
name: skip
in: query
description: Results to skip
required: false
schema:
type: integer
format: int32
responses:
veryBad:
description: failed
requestBodies:
UserArray:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
description: List of user object
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
securitySchemes:
api_key:
type: apiKey
name: api_key
in: header
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
scopes:
'write:pets': modify pets in your account
'read:pets': read your pets
schemas:
User:
properties:
id:
type: integer
format: int64
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
password:
type: string
phone:
type: string
userStatus:
type: integer
format: int32
description: User Status
xml:
name: User
Category:
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: Category
Pet:
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
$ref: '#/components/schemas/Category'
name:
type: string
example: doggie
photoUrls:
type: array
xml:
name: photoUrl
wrapped: true
items:
type: string
tags:
type: array
xml:
name: tag
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
xml:
name: Pet
Tag:
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: Tag
Order:
properties:
id:
type: integer
format: int64
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
shipDate:
type: string
format: date-time
status:
type: string
description: Order Status
complete:
type: boolean
xml:
name: Order
PetArray:
type: array
items:
$ref: '#/components/schemas/Pet'

View File

@@ -1,115 +0,0 @@
openapi: 3.0.0
info:
description: This is a simple API
version: "1.0.0"
title: Simple Inventory API
contact:
email: you@your-company.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: admins
description: Secured Admin-only calls
- name: developers
description: Operations available to regular developers
paths:
/inventory:
get:
tags:
- developers
summary: searches inventory
operationId: searchInventory
description: |
By passing in the appropriate options, you can search for
available inventory in the system
parameters:
- in: query
name: searchString
description: pass an optional search string for looking up inventory
required: false
schema:
type: string
- in: query
name: skip
description: number of records to skip for pagination
schema:
type: integer
format: int32
minimum: 0
- in: query
name: limit
description: maximum number of records to return
schema:
type: integer
format: int32
minimum: 0
maximum: 50
responses:
'200':
description: search results matching criteria
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/InventoryItem'
'400':
description: bad input parameter
post:
tags:
- admins
summary: adds an inventory item
operationId: addInventory
description: Adds an item to the system
responses:
'201':
description: item created
'400':
description: 'invalid input, object invalid'
'409':
description: an existing item already exists
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/InventoryItem'
description: Inventory item to add
components:
schemas:
InventoryItem:
type: object
required:
- id
- name
- manufacturer
- releaseDate
properties:
id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
name:
type: string
example: Widget Adapter
releaseDate:
type: string
format: date-time
example: '2016-08-29T09:12:33.001Z'
manufacturer:
$ref: '#/components/schemas/Manufacturer'
Manufacturer:
required:
- name
properties:
name:
type: string
example: ACME Corporation
homePage:
type: string
format: url
example: 'https://www.acme-corp.com'
phone:
type: string
example: 408-867-5309
type: object

View File

@@ -1,693 +0,0 @@
openapi: 3.0.0
info:
description: >
This is a sample server Petstore server.
[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.
For this sample, you can use the api key `special-key` to test the authorization filters
version: 1.0.0
title: Swagger Petstore
termsOfService: http://helloreverb.com/terms/
contact:
name: apiteam@swagger.io
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
tags:
- name: pet
description: Pet resource
- name: store
description: Store resource
- name: user
description: User resource
paths:
/pets:
post:
tags:
- pet
summary: Add a new pet to the store
description: ""
operationId: addPet
requestBody:
$ref: "#/components/requestBodies/Pet"
responses:
"405":
description: Invalid input
security:
- petstore_auth:
- write_pets
- read_pets
put:
tags:
- pet
summary: Update an existing pet
description: ""
operationId: updatePet
requestBody:
$ref: "#/components/requestBodies/Pet"
responses:
"400":
$ref: "#/components/responses/InvalidId"
"404":
description: Pet not found
"405":
description: Validation exception
security:
- petstore_auth:
- write_pets
- read_pets
/pets/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma seperated strings
operationId: findPetsByStatus
parameters:
- in: query
name: status
description: Status values that need to be considered for filter
required: false
explode: true
schema:
type: array
items:
type: string
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Pet"
application/xml:
schema:
type: array
items:
$ref: "#/components/schemas/Pet"
"400":
description: Invalid status value
security:
- petstore_auth:
- write_pets
- read_pets
/pets/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
description: Muliple tags can be provided with comma seperated strings. Use tag1,
tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- in: query
name: tags
description: Tags to filter by
required: false
example: adorable
explode: true
schema:
type: array
items:
type: string
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Pet"
application/xml:
schema:
type: array
items:
$ref: "#/components/schemas/Pet"
"400":
description: Invalid tag value
security:
- petstore_auth:
- write_pets
- read_pets
"/pets/{petId}":
get:
tags:
- pet
summary: Find pet by ID
description: Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
error conditions
operationId: getPetById
parameters:
- in: path
name: petId
description: ID of pet that needs to be fetched
required: true
example: 30
schema:
type: integer
format: int64
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
application/xml:
schema:
$ref: "#/components/schemas/Pet"
"400":
$ref: "#/components/responses/InvalidId"
"404":
description: Pet not found
security:
- api_key: []
- petstore_auth:
- write_pets
- read_pets
post:
tags:
- pet
summary: Updates a pet in the store with form data
description: ""
operationId: updatePetWithForm
parameters:
- in: path
name: petId
description: ID of pet that needs to be updated
required: true
schema:
type: string
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string
required:
- name
- status
responses:
"405":
description: Invalid input
security:
- petstore_auth:
- write_pets
- read_pets
delete:
tags:
- pet
summary: Deletes a pet
description: ""
operationId: deletePet
parameters:
- in: header
name: api_key
description: ""
required: true
schema:
type: string
- in: path
name: petId
description: Pet id to delete
required: true
schema:
type: integer
format: int64
responses:
"400":
description: Invalid pet value
security:
- petstore_auth:
- write_pets
- read_pets
/stores/order:
post:
tags:
- store
summary: Place an order for a pet
description: ""
operationId: placeOrder
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Order"
description: order placed for purchasing the pet
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
$ref: "#/components/schemas/Order"
application/xml:
schema:
$ref: "#/components/schemas/Order"
"400":
description: Invalid Order
"/stores/order/{orderId}":
get:
tags:
- store
summary: Find purchase order by ID
description: For valid response try integer IDs with value <= 5 or > 10. Other values
will generated exceptions
operationId: getOrderById
parameters:
- in: path
name: orderId
description: ID of pet that needs to be fetched
required: true
schema:
type: string
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
$ref: "#/components/schemas/Order"
application/xml:
schema:
$ref: "#/components/schemas/Order"
"400":
$ref: "#/components/responses/InvalidId"
"404":
description: Order not found
delete:
tags:
- store
summary: Delete purchase order by ID
description: For valid response try integer IDs with value < 1000. Anything above
1000 or nonintegers will generate API errors
operationId: deleteOrder
parameters:
- in: path
name: orderId
description: ID of the order that needs to be deleted
required: true
schema:
type: string
responses:
"400":
$ref: "#/components/responses/InvalidId"
"404":
description: Order not found
/users:
post:
tags:
- user
summary: Create user
description: This can only be done by the logged in user.
operationId: createUser
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/User"
description: Created user object
responses:
default:
description: successful operation
/users/createWithArray:
post:
tags:
- user
summary: Creates list of users with given input array
description: ""
operationId: createUsersWithArrayInput
requestBody:
$ref: "#/components/requestBodies/UserArray"
responses:
default:
description: successful operation
/users/createWithList:
post:
tags:
- user
summary: Creates list of users with given input array
description: ""
operationId: createUsersWithListInput
requestBody:
$ref: "#/components/requestBodies/UserArray"
responses:
default:
description: successful operation
/users/login:
get:
tags:
- user
summary: Logs user into the system
description: ""
operationId: loginUser
parameters:
- in: query
name: username
description: The user name for login
required: false
schema:
type: string
- in: query
name: password
description: The password for login in clear text
required: false
schema:
type: string
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
type: string
application/xml:
schema:
type: string
"400":
description: Invalid username/password supplied
/users/logout:
get:
tags:
- user
summary: Logs out current logged in user session
description: ""
operationId: logoutUser
responses:
default:
description: successful operation
"/users/{username}":
get:
tags:
- user
summary: Get user by user name
description: ""
operationId: getUserByName
parameters:
- in: path
name: username
description: The name that needs to be fetched. Use user1 for testing.
required: true
schema:
type: string
responses:
"200":
description: successful operation
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
content:
application/json:
schema:
$ref: "#/components/schemas/User"
application/xml:
schema:
$ref: "#/components/schemas/User"
"400":
description: Invalid username supplied
"404":
description: User not found
put:
tags:
- user
summary: Updated user
description: This can only be done by the logged in user.
operationId: updateUser
parameters:
- in: path
name: username
description: name that need to be deleted
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/User"
description: Updated user object
responses:
"400":
description: Invalid user supplied
"404":
description: User not found
delete:
tags:
- user
summary: Delete user
description: This can only be done by the logged in user.
operationId: deleteUser
parameters:
- in: path
name: username
description: The name that needs to be deleted
required: true
schema:
type: string
responses:
"400":
description: Invalid username supplied
"404":
description: User not found
externalDocs:
description: Find out more about Swagger
url: http://swagger.io
servers:
- url: http://petstore.swagger.io/v2
components:
responses:
InvalidId:
description: Invalid ID supplied
requestBodies:
UserArray:
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/User"
description: List of user object
Pet:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
application/xml:
schema:
$ref: "#/components/schemas/Pet"
description: Pet object that needs to be added to the store
securitySchemes:
api_key:
type: apiKey
name: api_key
in: header
description: This is another description
petstore_auth:
type: oauth2
description: This is a standard oauth flow
flows:
implicit:
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
scopes:
write_pets: modify pets in your account
read_pets: read your pets
schemas:
User:
type: object
properties:
id:
type: integer
format: int64
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
password:
type: string
phone:
type: string
userStatus:
type: integer
format: int32
description: User Status
Category:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
description: The name of the category
minLength: 0
maxLength: 255
pattern: "[A-Za-zäöüÄÖÜß]{0,255}"
default: DefaultCategory
example: FoobarCategory
Pet:
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
$ref: "#/components/schemas/Category"
name:
type: string
example: doggie
photoUrls:
type: array
items:
type: string
tags:
type: array
items:
$ref: "#/components/schemas/Tag"
status:
type: string
description: pet status in the store,
enum:
- Dead
- Alive
Tag:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
Order:
type: object
properties:
id:
type: integer
format: int64
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
minimum: 0
maximum: 10000
default: 0
example: 10
shipDate:
type: string
format: date-time
status:
type: string
description: Order Status
enum:
- Ordered
- Cancelled
complete:
type: boolean

View File

@@ -1,87 +0,0 @@
import java.text.SimpleDateFormat
Date buildTimeAndDate = new Date()
ext {
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
licenseUrl = 'https://github.com/Swagger2Markup/swagger2markup/blob/master/LICENSE.txt'
scmUrl = 'https://github.com/Swagger2Markup/swagger2markup.git'
}
def projectArtifactId = 'swagger2markup'
def projectUrl = 'https://github.com/Swagger2Markup/swagger2markup'
def licenseUrl = 'https://github.com/Swagger2Markup/swagger2markup/blob/master/LICENSE.txt'
def scmUrl = 'https://github.com/Swagger2Markup/swagger2markup.git'
def issuesUrl = 'https://github.com/Swagger2Markup/swagger2markup/issues'
jar {
manifest {
attributes(
'Built-By': 'Robert Winkler',
'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")",
'Build-Date': project.buildDate,
'Build-Time': project.buildTime,
'Specification-Title': projectArtifactId,
'Specification-Version': project.version,
'Implementation-Title': projectArtifactId,
'Implementation-Version': project.version
)
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
artifacts {
archives sourcesJar
archives javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom.withXml {
def devs = ['RobWin': 'Robert Winkler',
'austek': 'Ali Ustek']
def root = asNode()
root.dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
it.scope*.value = 'compile'
}
root.appendNode('name', projectArtifactId)
root.appendNode('packaging', 'jar')
root.appendNode('url', projectUrl)
root.appendNode('description', project.description)
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', 'Apache-2.0')
license.appendNode('url', licenseUrl)
license.appendNode('distribution', 'repo')
root.appendNode('scm').appendNode('url', scmUrl)
def developers = root.appendNode('developers')
devs.each {
def d = developers.appendNode('developer')
d.appendNode('id', it.key)
d.appendNode('name', it.value)
}
}
artifact sourcesJar
artifact javadocJar
}
}
}

View File

@@ -1,10 +0,0 @@
rootProject.name = 'swagger2markup'
include 'swagger2markup-asciidoc'
include 'swagger2markup-bom'
include 'swagger2markup-builder'
include 'swagger2markup-documentation'
include 'swagger2markup'
include 'swagger2markup-core'
include 'openapi2markup'

View File

@@ -1,25 +0,0 @@
ext.moduleName="io.github.swagger2markup.asciidoc"
dependencies {
configurations.all {
// resolutionStrategy.force dependencyOverrides.commonsCodec
// resolutionStrategy.force dependencyOverrides.commonsIO
// resolutionStrategy.force dependencyOverrides.commonsLang3
resolutionStrategy.force dependencyOverrides.jnrConstants
resolutionStrategy.force dependencyOverrides.jnrEnxio
resolutionStrategy.force dependencyOverrides.jnrPosix
// resolutionStrategy.force dependencyOverrides.jodaTime
resolutionStrategy.force dependencyOverrides.slf4j
// resolutionStrategy.force dependencyOverrides.jacksonDatabind
// resolutionStrategy.force dependencyOverrides.guava
// resolutionStrategy.force dependencyOverrides.findBugs
// resolutionStrategy.force dependencyOverrides.jaksonCore
}
implementation implLibraries.asciiDocJApi
implementation implLibraries.commonsText
implementation implLibraries.slf4j
testImplementation implLibraries.commonsIO
testImplementation testLibraries.asciiDocJ
testImplementation testLibraries.junit
testImplementation testLibraries.logback
}

View File

@@ -1,887 +0,0 @@
package io.github.swagger2markup.adoc;
import io.github.swagger2markup.adoc.converter.internal.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.asciidoctor.ast.List;
import org.asciidoctor.ast.*;
import org.asciidoctor.converter.ConverterFor;
import org.asciidoctor.converter.StringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.LongStream;
import java.util.stream.Stream;
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.*;
@ConverterFor(AsciidocConverter.NAME)
public class AsciidocConverter extends StringConverter {
private Logger logger = LoggerFactory.getLogger(getClass());
public static final String NAME = "adoc";
private final Pattern emptyLineOrStartWith = Pattern.compile("(?m)^\\s*(?:\\r?\\n)|(?m)^\\s+");
private final Pattern coListItemIdPattern = Pattern.compile(".*-(\\d+)");
private final Pattern tableColumnsStylePattern = Pattern.compile("((\\d+)\\*)?([<^>])?(\\.[<^>])?(\\d+)?([adehlmsv])?");
private static final java.util.List<String> attributeToExclude = Arrays.asList(
"localtime",
"filetype",
"asciidoctor-version",
"doctime",
"localyear",
"docdate",
"localdate",
"localdatetime",
"docdatetime",
"backend",
"basebackend",
"doctitle",
"docyear"
);
private static final String[] supportedUrlSchemes = new String[]{
"http",
"https",
"ftp",
"irc",
"mailto"
};
public AsciidocConverter(String backend, Map<String, Object> opts) {
super(backend, opts);
}
/**
* Converts an {@link ContentNode} using the specified transform along
* with additional options. If a transform is not specified, implementations
* typically derive one from the {@link ContentNode#getNodeName()} property.
*
* <p>Implementations are free to decide how to carry out the conversion. In
* the case of the built-in converters, the tranform value is used to
* dispatch to a handler method. The TemplateConverter uses the value of
* the transform to select a template to render.
*
* @param node The concrete instance of FlowNode to convert
* @param transform An optional String transform that hints at which transformation
* should be applied to this node. If a transform is not specified,
* the transform is typically derived from the value of the
* node's node_name property. (optional, default: null)
* @param opts An optional map of options that provide additional hints about
* how to convert the node. (optional, default: empty map)
* @return the converted result
*/
@Override
public String convert(ContentNode node, String transform, Map<Object, Object> opts) {
if (null == transform) {
transform = node.getNodeName();
}
switch (transform) {
case "inline_quoted":
return convertInlineQuoted((PhraseNode) node);
case "paragraph":
return convertParagraph((StructuralNode) node);
case "inline_anchor":
return convertInlineAnchor((PhraseNode) node);
case "section":
return convertSection((Section) node);
case "listing":
return convertListing((Block) node);
case "literal":
return convertLiteral((StructuralNode) node);
case "ulist":
return convertUList((List) node);
case "olist":
return convertOList((List) node);
case "dlist":
return convertDescriptionList((DescriptionList) node);
case "admonition":
return convertAdmonition((Block) node);
case "colist":
return convertCoList((List) node);
case "embedded":
case "document":
return convertEmbedded((Document) node);
case "example":
return convertExample((Block) node);
case "floating_title":
return convertFloatingTitle((StructuralNode) node);
case "image":
return convertImage((StructuralNode) node);
case "inline_break":
return convertInlineBreak(node);
case "inline_button":
return convertInlineButton(node);
case "inline_callout":
return convertInlineCallout(node);
case "inline_footnote":
return convertInlineFootnote(node);
case "inline_image":
return convertInlineImage((PhraseNode) node);
case "inline_indexterm":
return convertInlineIndexTerm(node);
case "inline_kbd":
return convertInlineKbd(node);
case "inline_menu":
return convertInlineMenu(node);
case "open":
return convertOpen((StructuralNode) node);
case "page_break":
return convertPageBreak(node);
case "preamble":
return convertPreamble((StructuralNode) node);
case "quote":
return convertQuote((StructuralNode) node);
case "sidebar":
return convertSidebar((StructuralNode) node);
case "stem":
return convertStem(node);
case "table":
return convertTable((Table) node);
case "thematic_break":
return convertThematicBreak(node);
case "verse":
return convertVerse((StructuralNode) node);
case "video":
return convertVideo(node);
case "toc":
return convertToc(node);
case "pass":
return convertPass(node);
case "audio":
return convertAudio(node);
// didn't exist on html converter
case "list":
return convertList((List) node);
case "list_item":
return convertListItem((ListItem) node);
default:
logger.debug("Don't know how to convert transform: [" + transform + "] Node: " + node);
return null;
}
}
String convertEmbedded(Document node) {
logger.debug("convertEmbedded");
StringBuilder sb = new StringBuilder();
appendId(node, sb);
if (StringUtils.isNotBlank(node.getDoctitle())) {
sb.append(repeat(node.getLevel() + 1,DOCUMENT_TITLE)).append(' ').append(StringEscapeUtils.unescapeHtml4(node.getDoctitle())).append(LINE_SEPARATOR);
}
Map<String, Object> attributes = node.getAttributes();
appendAuthors(sb, attributes);
appendRevisionDetails(sb, attributes);
appendDocumentAttributes(sb, attributes);
appendTrailingNewLine(sb);
appendChildBlocks(node, sb);
return sb.toString();
}
private void appendAuthors(StringBuilder sb, Map<String, Object> attributes) {
Long authorCount = (Long) attributes.getOrDefault("authorcount", 0L);
if (authorCount == 1) {
String author = getAuthorDetail(attributes, "author", "email");
if (StringUtils.isNotBlank(author)) {
sb.append(author).append(LINE_SEPARATOR);
}
} else if (authorCount > 1) {
String authors = LongStream.rangeClosed(1, authorCount)
.mapToObj(i -> getAuthorDetail(attributes, "author_" + i, "email_" + i))
.collect(Collectors.joining("; "));
if (StringUtils.isNotBlank(authors)) {
sb.append(authors).append(LINE_SEPARATOR);
}
}
}
private void appendDocumentAttributes(StringBuilder sb, Map<String, Object> attributes) {
attributes.forEach((k, v) -> {
if (!attributeToExclude.contains(k) && v != null && !v.toString().isEmpty())
sb.append(COLON).append(k).append(COLON).append(" ").append(v).append(LINE_SEPARATOR);
});
}
private void appendRevisionDetails(StringBuilder sb, Map<String, Object> attributes) {
String revDetails = Stream.of(attributes.get("revnumber"), attributes.get("revdate")).filter(Objects::nonNull)
.filter(o -> !o.toString().isEmpty()).map(Object::toString)
.collect(Collectors.joining(", "));
if (!revDetails.isEmpty()) {
sb.append("v").append(revDetails).append(LINE_SEPARATOR);
}
}
private String getAuthorDetail(Map<String, Object> attributes, String authorKey, String emailKey) {
String author = attributes.getOrDefault(authorKey, "").toString();
String email = attributes.getOrDefault(emailKey, "").toString();
if (StringUtils.isNotBlank(email)) {
email = " <" + email + ">";
}
return (author + email).trim();
}
private String convertInlineAnchor(PhraseNode node) {
logger.debug("convertInlineAnchor");
String type = node.getType();
switch (type) {
case "xref": {
String attrs;
String text;
String path = Optional.ofNullable(node.getAttributes().get("path")).orElse("").toString();
if (StringUtils.isNotBlank(path)) {
ArrayList<String> list = new ArrayList<>();
if (StringUtils.isNotBlank(node.getRole())) {
list.add(" class=\"#{node.role}\"");
}
append_link_constraint_attrs(node, list);
attrs = String.join(" ", list);
text = StringUtils.isNotBlank(node.getText()) ? node.getText() : path;
} else {
attrs = StringUtils.isNotBlank(node.getRole()) ? " class=\"" + node.getRole() + "\"" : "";
text = node.getText();
if (StringUtils.isNotBlank(text)) {
text = node.getAttributes().get("refid").toString();
}
}
return node.getTarget() + ATTRIBUTES_BEGIN + text + (StringUtils.isNotBlank(attrs) ? "," + attrs : "") + ATTRIBUTES_END;
}
case "ref":
return node.getId();
case "link": {
ArrayList<String> attrs = new ArrayList<>();
String target = node.getTarget();
String includePrefix = !StringUtils.startsWithAny(target, supportedUrlSchemes) ? "include::" : "";
String text = node.getText();
if (!target.equals(text)) {
attrs.add(text);
}
if (StringUtils.isNotBlank(node.getId())) {
attrs.add("id=\"" + node.getId() + "\"");
}
String role = node.getRole();
if (StringUtils.isNotBlank(role) && !role.equals("bare")) {
attrs.add("role=\"" + role + "\"");
}
String title = node.getAttribute("title", "").toString();
if (StringUtils.isNotBlank(title)) {
attrs.add("title=\"" + title + "\"");
}
return includePrefix + target + ATTRIBUTES_BEGIN + String.join(",", attrs) + ATTRIBUTES_END;
}
case "bibref":
return node.getId() + ATTRIBUTES_BEGIN + (StringUtils.isNotBlank(node.getReftext()) ? node.getReftext() : node.getId()) + ATTRIBUTES_END;
default:
logger.warn("unknown anchor type: " + node.getType());
return null;
}
}
private String convertAdmonition(Block node) {
logger.debug("convertAdmonition");
StringBuilder sb = new StringBuilder();
java.util.List<StructuralNode> blocks = node.getBlocks();
if (blocks.isEmpty()) {
sb.append(node.getStyle()).append(": ").append(node.getSource());
} else {
appendTitle(node, sb);
sb.append(ATTRIBUTES_BEGIN).append(node.getStyle()).append(ATTRIBUTES_END)
.append(LINE_SEPARATOR).append(DELIMITER_EXAMPLE).append(LINE_SEPARATOR);
appendChildBlocks(node, sb);
sb.append(DELIMITER_EXAMPLE).append(LINE_SEPARATOR);
}
return sb.toString();
}
private String convertInlineQuoted(PhraseNode node) {
logger.debug("convertInlineQuoted");
StringBuilder sb = new StringBuilder();
String marker = "";
switch (node.getType()) {
case "monospaced":
marker = "`";
break;
case "emphasis":
marker = "_";
break;
case "strong":
marker = "*";
break;
case "superscript":
marker = "^";
break;
case "subscript":
marker = "~";
break;
case "double":
case "single":
case "mark":
case "asciimath":
case "latexmath":
marker = "";
break;
}
sb.append(marker).append(node.getText()).append(marker);
return sb.toString();
}
private String convertFloatingTitle(StructuralNode node) {
logger.debug("convertFloatingTitle");
return ATTRIBUTES_BEGIN + "discrete" + ATTRIBUTES_END + LINE_SEPARATOR +
repeat(node.getLevel() + 1, TITLE) + ' ' + node.getTitle() + LINE_SEPARATOR;
}
private String convertExample(Block node) {
logger.debug("convertExample");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
sb.append(DELIMITER_EXAMPLE).append(LINE_SEPARATOR);
appendChildBlocks(node, sb);
sb.append(DELIMITER_EXAMPLE).append(LINE_SEPARATOR);
return sb.toString();
}
private String convertInlineButton(ContentNode node) {
logger.debug("convertInlineButton: name" + node.getNodeName());
return "convertInlineButton";
}
private String convertInlineCallout(ContentNode node) {
logger.debug("convertInlineCallout: name" + node.getNodeName());
return "convertInlineCallout";
}
private String convertInlineBreak(ContentNode node) {
logger.debug("convertInlineBreak: name" + node.getNodeName());
return "convertInlineBreak";
}
private String convertInlineFootnote(ContentNode node) {
logger.debug("convertInlineFootnote: name" + node.getNodeName());
return "convertInlineFootnote";
}
private String convertInlineImage(PhraseNode node) {
logger.debug("convertInlineImage");
if (node.getType().equals("icon")) {
return (new IconNode(node)).toAsciiDocContent();
} else {
return (new BlockImageNode(node)).toAsciiDocContent();
}
}
private String convertInlineIndexTerm(ContentNode node) {
logger.debug("convertInlineIndexTerm: name" + node.getNodeName());
return "convertInlineIndexTerm";
}
private String convertInlineKbd(ContentNode node) {
logger.debug("convertInlineKbd: name" + node.getNodeName());
return "convertInlineKbd";
}
private String convertInlineMenu(ContentNode node) {
logger.debug("convertInlineMenu: name" + node.getNodeName());
return "convertInlineMenu";
}
private String convertOpen(StructuralNode node) {
logger.debug("convertOpen");
StringBuilder sb = new StringBuilder();
switch (node.getStyle()) {
case "abstract":
sb.append(ATTRIBUTES_BEGIN).append("abstract").append(ATTRIBUTES_END).append(LINE_SEPARATOR);
break;
case "open":
sb.append(DELIMITER_OPEN_BLOCK).append(LINE_SEPARATOR);
}
sb.append(Optional.ofNullable(((Block) node).getSource()).orElse(""));
appendChildBlocks(node, sb);
if ("open".equals(node.getStyle())) {
sb.append(DELIMITER_OPEN_BLOCK).append(LINE_SEPARATOR);
}
return sb.toString();
}
private String convertPageBreak(ContentNode node) {
logger.debug("convertPageBreak: name" + node.getNodeName());
return DELIMITER_PAGE_BREAK + LINE_SEPARATOR;
}
private String convertQuote(StructuralNode node) {
logger.debug("convertQuote");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
sb.append(ATTRIBUTES_BEGIN);
java.util.List<String> attrs = new ArrayList<>();
if (StringUtils.isNotBlank(node.getStyle())) {
attrs.add("quote");
}
appendAttributeTo(node, attrs, "attribution");
appendAttributeTo(node, attrs, "citetitle");
sb.append(String.join(",", attrs)).append(ATTRIBUTES_END).append(LINE_SEPARATOR);
java.util.List<StructuralNode> blocks = node.getBlocks();
if (!blocks.isEmpty()) {
sb.append("____").append(LINE_SEPARATOR);
appendChildBlocks(node, sb);
sb.append("____").append(LINE_SEPARATOR);
} else {
sb.append(((Block) node).getSource());
}
return sb.toString();
}
private String convertSidebar(StructuralNode node) {
logger.debug("convertSidebar");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
appendChildBlocks(node, sb);
return sb.toString();
}
private String convertStem(ContentNode node) {
logger.debug("convertStem: name" + node.getNodeName());
return "convertStem";
}
private String convertThematicBreak(ContentNode node) {
logger.debug("convertThematicBreak: name" + node.getNodeName());
return DELIMITER_THEMATIC_BREAK + LINE_SEPARATOR;
}
private String convertVerse(StructuralNode node) {
logger.debug("convertVerse");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
sb.append(ATTRIBUTES_BEGIN);
java.util.List<String> attrs = new ArrayList<>();
if (StringUtils.isNotBlank(node.getStyle())) {
attrs.add("verse");
}
appendAttributeTo(node, attrs, "attribution");
appendAttributeTo(node, attrs, "citetitle");
sb.append(String.join(",", attrs)).append(ATTRIBUTES_END).append(LINE_SEPARATOR);
String source = ((Block) node).getSource();
boolean matches = emptyLineOrStartWith.matcher(source).find();
if (matches) {
sb.append(DELIMITER_VERSE).append(LINE_SEPARATOR);
}
sb.append(source);
if (matches) {
sb.append(LINE_SEPARATOR).append(DELIMITER_VERSE);
}
appendTrailingNewLine(sb);
return sb.toString();
}
private String convertVideo(ContentNode node) {
logger.debug("convertVideo: name" + node.getNodeName());
return "convertVideo";
}
private String convertToc(ContentNode node) {
logger.debug("convertToc: name" + node.getNodeName());
return "convertToc";
}
private String convertPass(ContentNode node) {
logger.debug("convertPass: name" + node.getNodeName());
return "convertPass";
}
private String convertAudio(ContentNode node) {
logger.debug("convertAudio: name" + node.getNodeName());
return "convertAudio";
}
private String convertCell(Cell node) {
logger.debug("convertCell");
StringBuilder sb = new StringBuilder();
String source = node.getSource();
if (StringUtils.isNotBlank(source)) {
sb.append(source);
}
Document innerDocument = node.getInnerDocument();
if (null != innerDocument) {
appendChildBlocks(innerDocument, sb, false);
}
return sb.toString().replaceAll(LINE_SEPARATOR + LINE_SEPARATOR + "+", LINE_SEPARATOR + LINE_SEPARATOR);
}
private String convertRow(Row node, java.util.List<TableCellStyle> columnStyles, String delimiterTableCell) {
logger.debug("convertRow");
StringBuilder sb = new StringBuilder();
node.getCells().forEach(cell -> {
boolean addNewLine = false;
int colspan = cell.getColspan();
if (colspan != 0) {
addNewLine = true;
sb.append(colspan).append('+');
}
int rowspan = cell.getRowspan();
if (rowspan != 0) {
addNewLine = true;
sb.append('.').append(rowspan).append('+');
}
int index = cell.getColumn().getColumnNumber() - 1;
TableCellStyle tableCellStyle = (columnStyles.size() > index) ? columnStyles.get(index) : null;
boolean hAlignmentAdded = false;
TableCellHorizontalAlignment hAlignment = TableCellHorizontalAlignment.fromName(cell.getHorizontalAlignment().name());
if ((null != hAlignment) && (null == tableCellStyle || hAlignment != tableCellStyle.horizontalAlignment)) {
hAlignmentAdded = true;
addNewLine = true;
sb.append(hAlignment.getDelimiter());
}
TableCellVerticalAlignment vAlignment = TableCellVerticalAlignment.fromName(cell.getVerticalAlignment().name());
if ((null != vAlignment) && (null == tableCellStyle || hAlignmentAdded || vAlignment != tableCellStyle.verticalAlignment)) {
addNewLine = true;
sb.append(vAlignment.getDelimiter());
}
Style style = Style.fromName(cell.getAttribute("style", "").toString());
if (null != style && (null == tableCellStyle || style != tableCellStyle.style)) {
addNewLine = true;
sb.append(style.getShortHand());
}
sb.append(delimiterTableCell).append(convertCell(cell));
if (addNewLine) {
sb.append(LINE_SEPARATOR);
} else {
sb.append(' ');
}
});
return sb.toString();
}
private String convertTable(Table node) {
logger.debug("convertTable");
java.util.List<TableCellStyle> columnStyles = new ArrayList<>();
for (String col : node.getAttribute("cols", "").toString().split(",")) {
Matcher matcher = tableColumnsStylePattern.matcher(col);
if (matcher.find()) {
int multiplier = 1;
String multiplierGroup = matcher.group(2);
if (null != multiplierGroup) {
try {
multiplier = Integer.parseInt(multiplierGroup);
} catch (NumberFormatException ignored) {
}
}
int width = 0;
try {
width = Integer.parseInt(matcher.group(5));
} catch (NumberFormatException ignored) {
}
TableCellStyle tableCellStyle = new TableCellStyle(
TableCellHorizontalAlignment.fromString(matcher.group(3)),
TableCellVerticalAlignment.fromString(matcher.group(4)),
Style.fromString(matcher.group(6)),
width
);
for (int i = 0; i < multiplier; i++) {
columnStyles.add(tableCellStyle);
}
}
}
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
sb.append(new TableNode(node).toAsciiDocContent());
boolean innerTable = isInnerTable(node);
String tableDelimiter = innerTable ? DELIMITER_INNER_TABLE : DELIMITER_TABLE;
String cellDelimiter = innerTable ? DELIMITER_INNER_TABLE_CELL : DELIMITER_TABLE_CELL;
sb.append(tableDelimiter).append(LINE_SEPARATOR);
appendRows(node.getHeader(), sb, columnStyles, cellDelimiter);
appendRows(node.getBody(), sb, columnStyles, cellDelimiter);
appendRows(node.getFooter(), sb, columnStyles, cellDelimiter);
sb.append(tableDelimiter).append(LINE_SEPARATOR);
return sb.toString();
}
private boolean isInnerTable(ContentNode node) {
if(null != node) {
ContentNode parent = node.getParent();
if (null != parent) {
return parent instanceof Table || isInnerTable(parent);
}
}
return false;
}
private void appendRows(java.util.List<Row> rows, StringBuilder sb, java.util.List<TableCellStyle> columnStyles, String delimiterTableCell) {
rows.forEach(row -> sb.append(convertRow(row, columnStyles, delimiterTableCell)).append(LINE_SEPARATOR));
}
private String convertDescriptionList(DescriptionList node) {
logger.debug("convertDescriptionList");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
String style = Optional.ofNullable(node.getStyle()).orElse("");
switch (style) {
case STYLE_HORIZONTAL:
sb.append(ATTRIBUTES_BEGIN).append(STYLE_HORIZONTAL).append(ATTRIBUTES_END).append(LINE_SEPARATOR);
node.getItems().forEach(item -> sb.append(convertDescriptionListEntry(item, node.getLevel(), false)));
break;
case STYLE_Q_AND_A:
sb.append(ATTRIBUTES_BEGIN).append(STYLE_Q_AND_A).append(ATTRIBUTES_END).append(LINE_SEPARATOR);
default:
node.getItems().forEach(item -> sb.append(convertDescriptionListEntry(item, node.getLevel(), true)));
break;
}
appendTrailingNewLine(sb);
return sb.toString();
}
private String convertDescriptionListEntry(DescriptionListEntry node, int level, Boolean descriptionOnNewLine) {
logger.debug("convertDescriptionListEntry");
StringBuilder sb = new StringBuilder();
String delimiter = repeat(level + 1, MARKER_D_LIST_ITEM);
String entryTerms = node.getTerms().stream()
.map(term -> Optional.ofNullable(term.getSource()).orElse(""))
.collect(Collectors.joining(delimiter + LINE_SEPARATOR, "", delimiter));
sb.append(entryTerms);
ListItem description = node.getDescription();
if (null != description) {
if (descriptionOnNewLine) {
sb.append(LINE_SEPARATOR);
}
String desc = Optional.ofNullable(description.getSource()).orElse("");
if (StringUtils.isNotBlank(desc)) {
sb.append(desc).append(LINE_SEPARATOR);
}
appendChildBlocks(description, sb);
}
return sb.toString();
}
private String convertListing(Block node) {
logger.debug("convertListing");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
if (STYLE_SOURCE.equals(node.getStyle())) {
sb.append(new SourceNode(node).toAsciiDocContent());
} else {
sb.append(new BlockListingNode(node).toAsciiDocContent());
}
return sb.toString();
}
private String convertUList(List node) {
logger.debug("convertUList");
StringBuilder sb = new StringBuilder();
appendStyle(node, sb);
appendTitle(node, sb);
appendChildBlocks(node, sb);
appendTrailingNewLine(sb);
return sb.toString();
}
private String convertOList(List node) {
logger.debug("convertOList");
StringBuilder sb = new StringBuilder();
java.util.List<String> attrs = new ArrayList<>();
String start = node.getAttribute("start", "").toString();
if (StringUtils.isNotBlank(start)) {
attrs.add("start=" + start);
}
if (node.isOption("reversed")) {
attrs.add("%reversed");
}
if (!attrs.isEmpty()) {
sb.append(ATTRIBUTES_BEGIN).append(String.join(",", attrs)).append(ATTRIBUTES_END).append(LINE_SEPARATOR);
}
appendTitle(node, sb);
appendChildBlocks(node, sb);
appendTrailingNewLine(sb);
return sb.toString();
}
private String convertCoList(List node) {
logger.debug("convertCoList");
StringBuilder result = new StringBuilder();
appendChildBlocks(node, result);
return result.toString();
}
private String convertListItem(ListItem node) {
logger.debug("convertListItem");
StringBuilder sb = new StringBuilder();
String marker = Optional.ofNullable(node.getMarker()).orElse(repeat(node.getLevel(), MARKER_LIST_ITEM));
String coids = node.getAttribute("coids", "").toString();
Matcher matcher = coListItemIdPattern.matcher(coids);
if (matcher.find()) {
marker = marker.replaceAll("\\d+", matcher.group(1));
}
sb.append(marker).append(" ");
if (node.hasAttribute("checkbox")) {
sb.append('[');
if (node.hasAttribute("checked")) {
sb.append('x');
} else {
sb.append(' ');
}
sb.append(']').append(' ');
}
sb.append(Optional.ofNullable(node.getSource()).orElse(""));
appendTrailingNewLine(sb);
appendChildBlocks(node, sb);
return sb.toString();
}
private String convertList(List node) {
logger.debug("convertList");
return node.getContent().toString();
}
private String convertPreamble(StructuralNode node) {
logger.debug("convertPreamble");
return node.getContent().toString();
}
private String convertImage(StructuralNode node) {
logger.debug("convertImage");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
appendRoles(node, sb);
sb.append(new BlockImageNode(node).toAsciiDocContent());
return sb.toString();
}
private String convertLiteral(StructuralNode node) {
logger.debug("convertLiteral");
return ATTRIBUTES_BEGIN + node.getContext() + ATTRIBUTES_END + LINE_SEPARATOR +
StringEscapeUtils.unescapeHtml4(node.getContent().toString()) + LINE_SEPARATOR;
}
private String convertParagraph(StructuralNode node) {
logger.debug("convertParagraph");
StringBuilder sb = new StringBuilder();
appendTitle(node, sb);
sb.append(new ParagraphAttributes(node).toAsciiDocContent());
appendSource((Block) node, sb);
appendTrailingNewLine(sb);
return sb.toString();
}
private String convertSection(Section node) {
logger.debug("convertSection");
StringBuilder sb = new StringBuilder();
appendId(node, sb);
sb.append(new DelimitedBlockNode(node).toAsciiDocContent()).append(StringUtils.repeat(TITLE, node.getLevel() + 1))
.append(" ").append(StringEscapeUtils.unescapeHtml4(node.getTitle())).append(LINE_SEPARATOR);
appendChildBlocks(node, sb);
appendTrailingNewLine(sb);
return sb.toString();
}
private void append_link_constraint_attrs(ContentNode node, java.util.List<String> attrs) {
String rel = node.getAttribute("nofollow-option").toString();
String window = node.getAttributes().get("window").toString();
if (StringUtils.isNotBlank(window)) {
attrs.add("target = \"#{window}\"");
if (window.equals("_blank") || (node.getAttributes().containsKey("option-noopener"))) {
if (StringUtils.isNotBlank(rel)) {
attrs.add("rel = \"" + rel + "noopener\"");
} else {
attrs.add(" rel=\"noopener\"");
}
}
} else if (StringUtils.isNotBlank(rel)) {
attrs.add("rel = " + rel + "\"");
}
}
private String repeat(int count, String with) {
return new String(new char[count]).replace("\0", with);
}
private void appendChildBlocks(StructuralNode parentNode, StringBuilder sb) {
appendChildBlocks(parentNode, sb, true);
}
private void appendChildBlocks(StructuralNode parentNode, StringBuilder sb, boolean addTrailingLineSeparator) {
final boolean isParentAListItem = parentNode instanceof ListItem || parentNode instanceof DescriptionListEntry;
parentNode.getBlocks().forEach(childNode -> {
String childNodeValue = childNode.convert();
if (StringUtils.isNotBlank(childNodeValue)) {
if (isParentAListItem && (sb.toString().contains("+" + LINE_SEPARATOR) || !(childNode instanceof List || childNode instanceof DescriptionList))) {
sb.append('+').append(LINE_SEPARATOR);
}
sb.append(childNodeValue);
if (addTrailingLineSeparator && !StringUtils.endsWith(childNodeValue, LINE_SEPARATOR)) {
sb.append(LINE_SEPARATOR);
}
}
});
}
private void appendTrailingNewLine(StringBuilder sb) {
if (!sb.toString().endsWith(LINE_SEPARATOR + LINE_SEPARATOR)) {
sb.append(LINE_SEPARATOR);
}
}
private void appendId(StructuralNode node, StringBuilder sb) {
String id = node.getId();
if (StringUtils.isNotBlank(id)) {
sb.append("[[").append(id).append("]]").append(LINE_SEPARATOR);
}
}
private void appendSource(Block node, StringBuilder sb) {
String source = node.getSource();
if (StringUtils.isNotBlank(source)) {
sb.append(source).append(LINE_SEPARATOR);
}
}
private void appendTitle(StructuralNode node, StringBuilder sb) {
String title = node.getTitle();
if (StringUtils.isNotBlank(title)) {
sb.append(".").append(StringEscapeUtils.unescapeHtml4(title)).append(LINE_SEPARATOR);
}
}
private void appendStyle(StructuralNode node, StringBuilder sb) {
String style = node.getStyle();
if (StringUtils.isNotBlank(style)) {
sb.append(ATTRIBUTES_BEGIN).append(style).append(ATTRIBUTES_END).append(LINE_SEPARATOR);
}
}
private void appendRoles(StructuralNode node, StringBuilder sb) {
java.util.List<String> roles = node.getRoles();
if (!roles.isEmpty()) {
sb.append(ATTRIBUTES_BEGIN).append(".").append(String.join(".", roles))
.append(ATTRIBUTES_END).append(LINE_SEPARATOR);
}
}
private void appendAttributeTo(StructuralNode node, java.util.List<String> attrs, String name) {
String attribution = node.getAttribute(name, "").toString();
if (StringUtils.isNotBlank(attribution)) {
attrs.add(attribution);
}
}
}

View File

@@ -1,70 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.Block;
import org.asciidoctor.ast.StructuralNode;
import java.util.*;
public class BlockImpl extends StructuralNodeImpl implements Block {
private List<String> lines;
public BlockImpl(StructuralNode parent, String context) {
this(parent, context, "");
}
public BlockImpl(StructuralNode parent, String context, Object content) {
this(parent, context, new HashMap<>(), content);
}
public BlockImpl(StructuralNode parent, String context, Map<String, Object> attributes) {
this(parent, context, attributes, "");
}
public BlockImpl(StructuralNode parent, String context, Map<String, Object> attributes, Object content) {
this(parent, context, attributes, new ArrayList<>(), content, new ArrayList<>(), "", new ArrayList<>());
}
public BlockImpl(StructuralNode parent, String context, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, String contentModel, List<String> subs) {
this(parent, context, attributes, roles, content, blocks, calculateLevel(parent), contentModel, subs);
}
public BlockImpl(StructuralNode parent, String context, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, Integer level, String contentModel, List<String> subs) {
super(parent, context, attributes, roles, content, blocks, level, contentModel, subs);
this.lines = new ArrayList<>();
}
@Override
@Deprecated
public List<String> lines() {
return getLines();
}
@Override
public List<String> getLines() {
return lines;
}
@Override
public void setLines(List<String> lines) {
this.lines = lines;
}
@Override
@Deprecated
public String source() {
return getSource();
}
@Override
public String getSource() {
return String.join("\n", lines);
}
@Override
public void setSource(String source) {
setLines(Arrays.asList(source.split("\n")));
}
}

View File

@@ -1,112 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.Cell;
import org.asciidoctor.ast.Column;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CellImpl extends ContentNodeImpl implements Cell {
private final int colspan;
private final int rowspan;
private String text;
private String style;
private Document innerDocument;
public CellImpl(Column parent, String text) {
this(parent, "table_cell", new HashMap<>(), new ArrayList<>(), 0, 0);
this.text = text;
}
public CellImpl(Column parent, Document innerDocument) {
this(parent, "table_cell", new HashMap<>(), new ArrayList<>(), 0, 0);
this.innerDocument = innerDocument;
}
public CellImpl(Column parent, String context, Map<String, Object> attributes, List<String> roles, int colspan, int rowspan) {
super(parent, context, attributes, roles);
this.colspan = colspan;
this.rowspan = rowspan;
}
@Override
public Column getColumn() {
return (Column) getParent();
}
@Override
public int getColspan() {
return colspan;
}
@Override
public int getRowspan() {
return rowspan;
}
@Override
public String getText() {
return text;
}
@Override
public String getSource() {
return text;
}
@Override
public void setSource(String source) {
this.text = source;
}
@Override
public Object getContent() {
return text;
}
@Override
public String getStyle() {
return style;
}
@Override
public void setStyle(String style) {
this.style = style;
}
@Override
public Table.HorizontalAlignment getHorizontalAlignment() {
return Table.HorizontalAlignment.valueOf(((String) getAttribute("halign", "left")).toUpperCase());
}
@Override
public void setHorizontalAlignment(Table.HorizontalAlignment halign) {
setAttribute("halign", halign.name().toLowerCase(), true);
}
@Override
public Table.VerticalAlignment getVerticalAlignment() {
return Table.VerticalAlignment.valueOf(((String) getAttribute("valign", "top")).toUpperCase());
}
@Override
public void setVerticalAlignment(Table.VerticalAlignment valign) {
setAttribute("valign", valign.name().toLowerCase(), true);
}
@Override
public Document getInnerDocument() {
return innerDocument;
}
@Override
public void setInnerDocument(Document document) {
this.innerDocument = document;
}
}

View File

@@ -1,81 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.Column;
import org.asciidoctor.ast.Table;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ColumnImpl extends ContentNodeImpl implements Column {
private String style;
private Number columnNumber = -1;
private Number width = 0;
public ColumnImpl(Table parent) {
this(parent, "table_column", new HashMap<>(), new ArrayList<>());
}
public ColumnImpl(Table parent, String context, Map<String, Object> attributes, List<String> roles) {
super(parent, context, attributes, roles);
}
@Override
public String getStyle() {
return style;
}
@Override
public void setStyle(String style) {
this.style = style;
}
@Override
public Table getTable() {
return (Table) getParent();
}
@Override
public int getColumnNumber() {
return columnNumber.intValue();
}
public void setColumnNumber(Integer columnNumber) {
setAttribute("colnumber", columnNumber, true);
this.columnNumber = columnNumber;
}
@Override
public int getWidth() {
return width.intValue();
}
@Override
public void setWidth(int width) {
setAttribute("width", width, true);
this.width = width;
}
@Override
public Table.HorizontalAlignment getHorizontalAlignment() {
return Table.HorizontalAlignment.valueOf(((String) getAttribute("halign", "left")).toUpperCase());
}
@Override
public void setHorizontalAlignment(Table.HorizontalAlignment halign) {
setAttribute("halign", halign.name().toLowerCase(), true);
}
@Override
public Table.VerticalAlignment getVerticalAlignment() {
return Table.VerticalAlignment.valueOf(((String) getAttribute("valign", "top")).toUpperCase());
}
@Override
public void setVerticalAlignment(Table.VerticalAlignment valign) {
setAttribute("valign", valign.name().toLowerCase(), true);
}
}

View File

@@ -1,309 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.ContentNode;
import org.asciidoctor.ast.Document;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SuppressWarnings("SuspiciousMethodCalls")
public abstract class ContentNodeImpl implements ContentNode {
private String id;
private final String context;
private final Map<String, Object> attributes;
private final List<String> roles;
private final ContentNode parent;
public ContentNodeImpl(ContentNode parent, String context) {
this(parent, context, new HashMap<>(), new ArrayList<>());
}
public ContentNodeImpl(ContentNode parent, String context, Map<String, Object> attributes, List<String> roles) {
this.parent = parent;
this.context = context;
this.attributes = attributes;
this.roles = roles;
}
@Override
@Deprecated
public String id() {
return getId();
}
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id.toLowerCase().replaceAll("\\s+", "_");
}
@Override
@Deprecated
public String context() {
return getContext();
}
@Override
public String getContext() {
return context;
}
@Override
@Deprecated
public ContentNode parent() {
return getParent();
}
@Override
public ContentNode getParent() {
return parent;
}
@Override
@Deprecated
public Document document() {
return getDocument();
}
@Override
public Document getDocument() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String getNodeName() {
return getContext();
}
@Override
public boolean isInline() {
return false;
}
@Override
public boolean isBlock() {
return false;
}
@Override
public Map<String, Object> getAttributes() {
return attributes;
}
@Override
@Deprecated
public Object getAttr(Object name, Object defaultValue, boolean inherit) {
return getAttribute(name, defaultValue, inherit);
}
@Override
@Deprecated
public Object getAttr(Object name, Object defaultValue) {
return getAttribute(name, defaultValue);
}
@Override
@Deprecated
public Object getAttr(Object name) {
return getAttribute(name);
}
@Override
public Object getAttribute(Object name, Object defaultValue, boolean inherit) {
return getAttribute(name, defaultValue);
}
@Override
public Object getAttribute(Object name, Object defaultValue) {
return attributes.getOrDefault(name, defaultValue);
}
@Override
public Object getAttribute(Object name) {
return attributes.get(name);
}
@Override
@Deprecated
public boolean isAttr(Object name, Object expected, boolean inherit) {
return isAttribute(name, expected, inherit);
}
@Override
@Deprecated
public boolean isAttr(Object name, Object expected) {
return isAttribute(name, expected);
}
@Override
public boolean isAttribute(Object name, Object expected, boolean inherit) {
return isAttribute(name, expected);
}
@Override
public boolean isAttribute(Object name, Object expected) {
try {
if (attributes.containsKey(name)) {
return attributes.get(name).equals(expected);
} else return false;
} catch (Exception e) {
return false;
}
}
@Override
@Deprecated
public boolean hasAttr(Object name) {
return hasAttribute(name);
}
@Override
@Deprecated
public boolean hasAttr(Object name, boolean inherited) {
return hasAttribute(name, inherited);
}
@Override
public boolean hasAttribute(Object name) {
return attributes.containsKey(name);
}
@Override
public boolean hasAttribute(Object name, boolean inherited) {
return hasAttribute(name);
}
@Override
@Deprecated
public boolean setAttr(Object name, Object value, boolean overwrite) {
return setAttribute(name, value, overwrite);
}
@Override
public boolean setAttribute(Object name, Object value, boolean overwrite) {
return setAttribute((String)name, value, overwrite);
}
public boolean setAttribute(String name, Object value, boolean overwrite) {
try {
if (overwrite) {
attributes.put(name, value);
} else {
attributes.putIfAbsent(name, value);
}
return true;
} catch (Exception e) {
return false;
}
}
public Object removeAttribute(String name){
return attributes.remove(name);
}
public boolean removeAttribute(String name, Object value){
return attributes.remove(name, value);
}
@Override
public boolean isOption(Object name) {
try {
Object o = attributes.get(name + "-option");
return null != o && o.toString().equals("");
}catch (Exception ignored){
return false;
}
}
public boolean setOption(String name){
return setAttribute(name + "-option", "", true);
}
public Object removeOption(String name){
return removeAttribute(name + "-option");
}
@Override
public boolean isRole() {
return false;
}
@Override
public String getRole() {
return String.join(",", roles);
}
@Override
@Deprecated
public String role() {
return getRole();
}
@Override
public List<String> getRoles() {
return roles;
}
@Override
public boolean hasRole(String role) {
return roles.contains(role);
}
@Override
public void addRole(String role) {
roles.add(role);
}
@Override
public void removeRole(String role) {
roles.remove(role);
}
@Override
public boolean isReftext() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String getReftext() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String iconUri(String name) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String mediaUri(String target) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String imageUri(String targetImage) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String imageUri(String targetImage, String assetDirKey) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String readAsset(String path, Map<Object, Object> opts) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String normalizeWebPath(String path, String start, boolean preserveUriTarget) {
throw new UnsupportedOperationException("Not implemented, yet");
}
}

View File

@@ -1,36 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.Cursor;
public class CursorImpl implements Cursor {
private int lineno;
public CursorImpl() {
}
@Override
public int getLineNumber() {
return lineno;
}
@Override
public String getPath() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String getDir() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String getFile() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public String toString() {
throw new UnsupportedOperationException("Not implemented, yet");
}
}

View File

@@ -1,66 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.DescriptionListEntry;
import org.asciidoctor.ast.ListItem;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DescriptionListEntryImpl extends StructuralNodeImpl implements DescriptionListEntry {
private final List<ListItem> terms;
private ListItem description;
public DescriptionListEntryImpl(StructuralNode parent) {
this(parent, new ArrayList<>());
}
public DescriptionListEntryImpl(StructuralNode parent, List<ListItem> terms) {
this(parent, terms, null);
}
public DescriptionListEntryImpl(StructuralNode parent, List<ListItem> terms, ListItem description) {
this(parent, null, terms, description);
}
public DescriptionListEntryImpl(StructuralNode parent, Object content, List<ListItem> terms, ListItem description) {
this(parent, new HashMap<>(), new ArrayList<>(), content, new ArrayList<>(), "", new ArrayList<>(), terms, description);
}
public DescriptionListEntryImpl(StructuralNode parent, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, String contentModel, List<String> subs,
List<ListItem> terms, ListItem description) {
this(parent, attributes, roles, content, blocks, null != parent ? parent.getLevel() : 1, contentModel, subs, terms, description);
}
public DescriptionListEntryImpl(StructuralNode parent, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, Integer level, String contentModel,
List<String> subs, List<ListItem> terms, ListItem description) {
super(parent, "dlist_item", attributes, roles, content, blocks, level, contentModel, subs);
this.terms = terms;
this.description = description;
}
@Override
public List<ListItem> getTerms() {
return terms;
}
public boolean addTerm(ListItem term) {
return terms.add(term);
}
@Override
public ListItem getDescription() {
return description;
}
public void setDescription(final ListItem description) {
this.description = description;
}
}

View File

@@ -1,72 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.DescriptionList;
import org.asciidoctor.ast.DescriptionListEntry;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DescriptionListImpl extends StructuralNodeImpl implements DescriptionList {
public static final String CONTEXT = "dlist";
private List<DescriptionListEntry> items;
public DescriptionListImpl(StructuralNode parent) {
this(parent, new ArrayList<>());
}
public DescriptionListImpl(StructuralNode parent, List<DescriptionListEntry> items) {
this(parent, null, items);
}
public DescriptionListImpl(StructuralNode parent, Object content, List<DescriptionListEntry> items) {
this(parent, new HashMap<>(), new ArrayList<>(), content, new ArrayList<>(), "", new ArrayList<>(), items);
}
public DescriptionListImpl(StructuralNode parent, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, String contentModel,
List<String> subs, List<DescriptionListEntry> items) {
this(parent, attributes, roles, content, blocks, calculateLevel(parent), contentModel, subs, items);
}
public DescriptionListImpl(StructuralNode parent, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, Integer level,
String contentModel, List<String> subs, List<DescriptionListEntry> items) {
super(parent, CONTEXT, attributes, roles, content, blocks, level, contentModel, subs);
this.items = items;
}
@Override
public List<DescriptionListEntry> getItems() {
return items;
}
public void setItems(List<DescriptionListEntry> items) {
this.items = items;
}
public void addEntry(DescriptionListEntry entry) {
this.items.add(entry);
}
@Override
public boolean hasItems() {
return !items.isEmpty();
}
@Override
@Deprecated
public String render() {
return convert();
}
protected static Integer calculateLevel(StructuralNode parent) {
int level = 1;
if (parent instanceof DescriptionList)
level = parent.getLevel() + 1;
return level;
}
}

View File

@@ -1,89 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.Document;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.ast.Title;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DocumentImpl extends StructuralNodeImpl implements Document {
public DocumentImpl() {
this(null);
}
public DocumentImpl(StructuralNode parent) {
this(parent, "document", "");
}
public DocumentImpl(StructuralNode parent, String context, Object content) {
this(parent, context, new HashMap<>(), new ArrayList<>(), content, new ArrayList<>(), "", new ArrayList<>());
}
public DocumentImpl(StructuralNode parent, String context, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, String contentModel,
List<String> subs) {
this(parent, context, attributes, roles, content, blocks, null != parent ? parent.getLevel() + 1 : 0, contentModel, subs);
}
public DocumentImpl(StructuralNode parent, String context, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, Integer level, String contentModel,
List<String> subs) {
super(parent, context, attributes, roles, content, blocks, level, contentModel, subs);
}
@Override
public boolean isBasebackend(String backend) {
return isAttribute("basebackend", backend);
}
@Override
@Deprecated
public boolean basebackend(String backend) {
return isBasebackend(backend);
}
@Override
public Map<Object, Object> getOptions() {
return null;
}
@Override
public Title getStructuredDoctitle() {
return (Title) getOptions().get("doctitle");
}
@Override
public String getDoctitle() {
return getTitle();
}
@Override
@Deprecated
public String doctitle() {
return getDoctitle();
}
@Override
public int getAndIncrementCounter(String name) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public int getAndIncrementCounter(String name, int initialValue) {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public boolean isSourcemap() {
throw new UnsupportedOperationException("Not implemented, yet");
}
@Override
public void setSourcemap(boolean state) {
throw new UnsupportedOperationException("Not implemented, yet");
}
}

View File

@@ -1,56 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.List;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class ListImpl extends StructuralNodeImpl implements List {
private final java.util.List<StructuralNode> items;
public ListImpl(StructuralNode parent, String context) {
this(parent, context, new ArrayList<>());
}
public ListImpl(StructuralNode parent, String context, java.util.List<StructuralNode> items) {
this(parent, context, null, items);
}
public ListImpl(StructuralNode parent, String context, Object content, java.util.List<StructuralNode> items) {
this(parent, context, new HashMap<>(), new ArrayList<>(), content, new ArrayList<>(), "", new ArrayList<>(), items);
}
public ListImpl(StructuralNode parent, String context, Map<String, Object> attributes, java.util.List<String> roles,
Object content, java.util.List<StructuralNode> blocks,
String contentModel, java.util.List<String> subs, java.util.List<StructuralNode> items) {
this(parent, context, attributes, roles, content, blocks, null != parent ? parent.getLevel() + 1 : 0, contentModel, subs, items);
}
public ListImpl(StructuralNode parent, String context, Map<String, Object> attributes, java.util.List<String> roles,
Object content, java.util.List<StructuralNode> blocks,
Integer level, String contentModel, java.util.List<String> subs, java.util.List<StructuralNode> items) {
super(parent, context, attributes, roles, content, blocks, level, contentModel, subs);
this.items = items;
}
@Override
public java.util.List<StructuralNode> getItems() {
return items;
}
@Override
public boolean hasItems() {
return !items.isEmpty();
}
@Override
@Deprecated
public String render() {
return convert();
}
}

View File

@@ -1,63 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.apache.commons.lang3.StringUtils;
import org.asciidoctor.ast.ListItem;
import org.asciidoctor.ast.StructuralNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ListItemImpl extends StructuralNodeImpl implements ListItem {
private final String marker;
private String text;
public ListItemImpl(StructuralNode parent, String text) {
this(parent, "list_item", null, "*", text);
}
public ListItemImpl(StructuralNode parent, String context, Object content, String marker, String text) {
this(parent, context, new HashMap<>(), new ArrayList<>(), content, new ArrayList<>(), "", new ArrayList<>(), marker, text);
}
public ListItemImpl(StructuralNode parent, String context, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, String contentModel,
List<String> subs, String marker, String text) {
this(parent, context, attributes, roles, content, blocks, null != parent ? parent.getLevel() : 1, contentModel, subs, marker, text);
}
public ListItemImpl(StructuralNode parent, String context, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, Integer level,
String contentModel, List<String> subs, String marker, String text) {
super(parent, context, attributes, roles, content, blocks, level, contentModel, subs);
this.marker = marker;
this.text = text;
}
@Override
public String getMarker() {
return marker;
}
@Override
public String getText() {
return text;
}
@Override
public String getSource() {
return text;
}
@Override
public void setSource(String source) {
this.text = source;
}
@Override
public boolean hasText() {
return StringUtils.isNotBlank(text);
}
}

View File

@@ -1,38 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import org.asciidoctor.ast.StructuralNode;
import java.util.List;
import java.util.Map;
public class ParagraphBlockImpl extends BlockImpl {
public static final String CONTEXT = "paragraph";
public ParagraphBlockImpl(StructuralNode parent) {
super(parent, CONTEXT);
}
public ParagraphBlockImpl(StructuralNode parent, Object content) {
super(parent, CONTEXT, content);
}
public ParagraphBlockImpl(StructuralNode parent, Map<String, Object> attributes) {
super(parent, CONTEXT, attributes);
}
public ParagraphBlockImpl(StructuralNode parent, Map<String, Object> attributes, Object content) {
super(parent, CONTEXT, attributes, content);
}
public ParagraphBlockImpl(StructuralNode parent, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, String contentModel, List<String> subs) {
super(parent, CONTEXT, attributes, roles, content, blocks, contentModel, subs);
}
public ParagraphBlockImpl(StructuralNode parent, Map<String, Object> attributes, List<String> roles,
Object content, List<StructuralNode> blocks, Integer level, String contentModel,
List<String> subs) {
super(parent, CONTEXT, attributes, roles, content, blocks, level, contentModel, subs);
}
}

View File

@@ -1,50 +0,0 @@
package io.github.swagger2markup.adoc.ast.impl;
import io.github.swagger2markup.adoc.AsciidocConverter;
import org.asciidoctor.ast.ContentNode;
import org.asciidoctor.ast.PhraseNode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PhraseNodeImpl extends ContentNodeImpl implements PhraseNode {
private final String type;
private final String text;
private final String target;
private final AsciidocConverter converter = new AsciidocConverter(AsciidocConverter.NAME, new HashMap<>());
public PhraseNodeImpl(ContentNode parent, String context, Map<String, Object> attributes, List<String> roles, String type, String text, String target) {
super(parent, context, attributes, roles);
this.type = type;
this.text = text;
this.target = target;
}
@Override
@Deprecated
public String render() {
return convert();
}
@Override
public String convert() {
return converter.convert(this, null, new HashMap<>());
}
@Override
public String getType() {
return type;
}
@Override
public String getText() {
return text;
}
@Override
public String getTarget() {
return target;
}
}

Some files were not shown because too many files have changed in this diff Show More