Compare commits
243 Commits
Author | SHA1 | Date | |
---|---|---|---|
f874cb74e3 | |||
9bd3b2e1e6 | |||
0958d5a874 | |||
c53c0b045d | |||
fb0d3bb1dd | |||
1580d679d0 | |||
540dad1f00 | |||
21f922a296 | |||
fa7b1e5833 | |||
35110e8ad4 | |||
18d64a2ed1 | |||
4ffb04976a | |||
76b6288216 | |||
80f6f28b57 | |||
bf8b2b40f6 | |||
7c6826b366 | |||
ee56c8023e | |||
01c4e0558d | |||
a760121af5 | |||
b80ff3a998 | |||
8141be4b21 | |||
7fbc2523e2 | |||
3349e9dab7 | |||
da8439e1b7 | |||
e2d7d16571 | |||
f348910b63 | |||
7ed4c8075b | |||
87ba80b6bb | |||
e10f3b4c47 | |||
a7853ce353 | |||
da654e5664 | |||
d21434fdd0 | |||
8a94f6e498 | |||
7a58914466 | |||
2da6088303 | |||
1ad82f7e8e | |||
6117443c8b | |||
f8e098eb07 | |||
e2affe3f4b | |||
a78b51be07 | |||
fa96923a5a | |||
464fa2d98a | |||
11e0d248b5 | |||
2612010a88 | |||
cb78d19b89 | |||
28bce9c443 | |||
d7dad48808 | |||
2ea97ba2c2 | |||
944c632a1d | |||
d1c52c010e | |||
d9f78b4e9f | |||
dcde50de0a | |||
889fdb41d7 | |||
837108bbef | |||
ee9e3b03b3 | |||
3cc6e9f2e7 | |||
60eb3b6474 | |||
65c0137a46 | |||
c277e559f4 | |||
8a161466d6 | |||
9a4ad2f737 | |||
eb4d3ca7de | |||
7a8bb43675 | |||
ac464ea9ca | |||
c7545b1072 | |||
353637bb94 | |||
3d1fc566d4 | |||
79ddb2e4ae | |||
d004166a2e | |||
dc6dbdf1c0 | |||
0b9b8325ce | |||
6d89773448 | |||
b236530991 | |||
8caee55f43 | |||
13042ba385 | |||
26bd7178c9 | |||
9bc39e9767 | |||
57555587e0 | |||
47a9f0a145 | |||
789b750994 | |||
65fb7fbd55 | |||
89bd9dadd0 | |||
6ca8261cd2 | |||
ae5ddc35e6 | |||
dde9e1c0a7 | |||
8328351227 | |||
36a09ef3ca | |||
261e91a750 | |||
701ab7670e | |||
62280435cd | |||
18ddb13625 | |||
b5b2e462ac | |||
1bb52347a0 | |||
80f8ce6e52 | |||
1f504e8850 | |||
18d545bbfe | |||
e03868c42e | |||
e888207773 | |||
66943ceb5a | |||
e9342b9354 | |||
480b1ccdff | |||
95009090ba | |||
10ce370c9e | |||
1814fe4eb2 | |||
b0387313fd | |||
86c4800748 | |||
01052268f8 | |||
5c6f2c93e8 | |||
ccd46b15e7 | |||
eab1bb4ce7 | |||
3fdfe875f4 | |||
1b3cf0dbeb | |||
2410c81797 | |||
833bf463e7 | |||
b7e96019be | |||
aa5eb39a30 | |||
d002ec7fd9 | |||
650eb0f0d3 | |||
1a4568a49b | |||
f2786fec08 | |||
904cc6816d | |||
a06821a910 | |||
a9dffcf8a5 | |||
548b1ff4bc | |||
6f85ee476a | |||
326bbb4419 | |||
438eb52dc8 | |||
1fd59db4e1 | |||
238e372460 | |||
473e2c22af | |||
7fb7e688ac | |||
9f2c27aa0f | |||
dc762d1d3e | |||
b039803246 | |||
6ec240d7cd | |||
dd57347b90 | |||
43c8fd1338 | |||
6c2725680e | |||
84dfe4e6fe | |||
a0c1abf011 | |||
25820d0920 | |||
7c18283ac8 | |||
c5f3b7fa8b | |||
8b81010d72 | |||
c07ffa6a14 | |||
7793908ab6 | |||
bf6d08c2bd | |||
68bae4918e | |||
592c116c3b | |||
c7fe5c288f | |||
e059633055 | |||
884a50fc83 | |||
588e52c9df | |||
f49fcb2a22 | |||
0a9475a7ab | |||
f8fbb7ad25 | |||
f792fb5d1f | |||
845d1a971d | |||
9396b2ecfe | |||
d74b7b3f28 | |||
e783630845 | |||
d907ba004a | |||
5c7ec4fdb4 | |||
097413067b | |||
eb7360b8d2 | |||
3ec467c1d8 | |||
152476c26e | |||
c4df4c7b2c | |||
87fa0b5602 | |||
53c76d6037 | |||
44324ca3a4 | |||
9364fb19e4 | |||
ca1f632665 | |||
9bb3184735 | |||
9a139b5713 | |||
9861c8e258 | |||
02f8ed04f2 | |||
3e23939386 | |||
d0575944db | |||
ccc81c2813 | |||
e8da52fd75 | |||
34c14e26da | |||
209b5e38a3 | |||
902faa9471 | |||
c7ef70a844 | |||
f83c3d203d | |||
bd05dbcfcb | |||
cb5c0e71a3 | |||
a209cafa74 | |||
3d27d30a31 | |||
8cc229667e | |||
54d12de67a | |||
9b93c887a2 | |||
19d828956b | |||
eabe90acfc | |||
7c2a2a9c9d | |||
15cdfb229d | |||
5a40f37f81 | |||
64f2516f19 | |||
2e5e39d3b2 | |||
5342cf00d1 | |||
8c0b658033 | |||
b7b1171685 | |||
1f730869a8 | |||
377a60614e | |||
e34bea1769 | |||
91bf93a866 | |||
73fb8b137f | |||
d3d6e79329 | |||
f2b7d924e0 | |||
f62010b4e7 | |||
5bd1534270 | |||
4c151ffeea | |||
08a0d2e47c | |||
f19476d3a3 | |||
8ede53fd5c | |||
31a9f44ec1 | |||
0eb2f126b3 | |||
0d658bd6a8 | |||
e924671c2b | |||
04996631b9 | |||
82d80873c8 | |||
487eaba741 | |||
b935cc1e1d | |||
9f2d2dd4e3 | |||
20f8a4f08f | |||
7b39e448bf | |||
3c57c8f5e4 | |||
01b6b59cf5 | |||
2c1c8fbcdc | |||
0dc2b9538f | |||
1ca7abaf0d | |||
a5376cfa82 | |||
2492661f1f | |||
a7b52ec114 | |||
8ebab04a83 | |||
921f6f9691 | |||
558b9fea62 | |||
752cb238d3 | |||
92d4760dbc | |||
4946a27327 | |||
e4217843b7 | |||
b8f2090a8a |
10
.envrc
Normal file
10
.envrc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
|
||||||
|
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
|
||||||
|
fi
|
||||||
|
|
||||||
|
watch_file flake.nix
|
||||||
|
watch_file flake.lock
|
||||||
|
if ! use flake . --impure
|
||||||
|
then
|
||||||
|
echo "Flake could not be used... something is broken :(" >&2
|
||||||
|
fi
|
17
.github/ISSUE_TEMPLATE/documentation.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/documentation.md
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: Documentation
|
||||||
|
about: Suggest an improvement to the documentation for Kompendium
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Please describe the problem with the current documentation.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Link any docs references**
|
||||||
|
Link to existing docs if incorrect, or references from another project if you have an example.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
12
.github/workflows/autoupdate.yml
vendored
12
.github/workflows/autoupdate.yml
vendored
@ -1,12 +0,0 @@
|
|||||||
name: autoupdate
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
jobs:
|
|
||||||
autoupdate:
|
|
||||||
name: autoupdate
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: docker://chinthakagodawita/autoupdate-action:v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
|
18
.github/workflows/pr_checks.yml
vendored
18
.github/workflows/pr_checks.yml
vendored
@ -4,12 +4,12 @@ jobs:
|
|||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
- name: Lint
|
- name: Lint
|
||||||
uses: burrunan/gradle-cache-action@v1
|
uses: burrunan/gradle-cache-action@v1
|
||||||
with:
|
with:
|
||||||
@ -18,14 +18,14 @@ jobs:
|
|||||||
unit:
|
unit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
- name: Unit Tests
|
- name: Unit Tests
|
||||||
uses: burrunan/gradle-cache-action@v1
|
uses: burrunan/gradle-cache-action@v1
|
||||||
with:
|
with:
|
||||||
gradle-version: wrapper
|
gradle-version: wrapper
|
||||||
arguments: test koverMergedReport
|
arguments: test koverHtmlReport
|
||||||
|
25
.github/workflows/publish.yml
vendored
25
.github/workflows/publish.yml
vendored
@ -1,25 +0,0 @@
|
|||||||
name: Publish to GitHub Packages
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
paths-ignore:
|
|
||||||
- docs/**
|
|
||||||
env:
|
|
||||||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_SIGNING_KEY }}
|
|
||||||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: 'adopt'
|
|
||||||
java-version: '17'
|
|
||||||
- name: Publish to GitHub Packages
|
|
||||||
uses: burrunan/gradle-cache-action@v1
|
|
||||||
with:
|
|
||||||
gradle-version: wrapper
|
|
||||||
arguments: publishAllPublicationsToGithubPackagesRepository
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
21
.github/workflows/release.yml
vendored
21
.github/workflows/release.yml
vendored
@ -4,25 +4,26 @@ on:
|
|||||||
types:
|
types:
|
||||||
- prereleased
|
- prereleased
|
||||||
- released
|
- released
|
||||||
env:
|
|
||||||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_SIGNING_KEY }}
|
|
||||||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-to-nexus:
|
publish-to-maven-central:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v3
|
- uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
- name: Publish to Maven Central
|
- name: Publish to Maven Central
|
||||||
uses: burrunan/gradle-cache-action@v1
|
uses: burrunan/gradle-cache-action@v1
|
||||||
with:
|
with:
|
||||||
gradle-version: wrapper
|
gradle-version: wrapper
|
||||||
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
|
arguments: publishAndReleaseToMavenCentral --no-configuration-cache --stacktrace
|
||||||
properties: |
|
properties: |
|
||||||
release=true
|
release=true
|
||||||
env:
|
env:
|
||||||
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USER }}
|
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
|
||||||
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
|
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
|
||||||
|
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_SIGNING_KEY }}
|
||||||
|
# NOTE: FML https://stackoverflow.com/a/39573795
|
||||||
|
ORG_GRADLE_PROJECT_signingInMemoryKeyId: FF618132
|
||||||
|
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_SIGNING_PASSWORD }}
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.gradle
|
.gradle
|
||||||
build
|
build
|
||||||
.idea
|
.idea
|
||||||
|
.direnv
|
||||||
|
126
CHANGELOG.md
126
CHANGELOG.md
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Updates for Ktor 3.x support
|
||||||
|
- Remove deprecated `NotarizedLocations`
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
@ -12,6 +15,129 @@
|
|||||||
|
|
||||||
## Released
|
## Released
|
||||||
|
|
||||||
|
## [4.0.0] - January 21st, 2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- All changes from alpha release
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Enrichments now mirror schema types
|
||||||
|
|
||||||
|
## [4.0.0-alpha] - September 3rd, 2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for `type` on sealed interfaces
|
||||||
|
- Ability to provide custom serializers
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Exception thrown when inheriting variable
|
||||||
|
- Notarized routes not discarded on test completion
|
||||||
|
- Data classes with property members breaks schema generation
|
||||||
|
- Security cannot be applied to individual path operations
|
||||||
|
- Serialization fails on generic response
|
||||||
|
- Parameter example descriptions not being applied
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Out of the box support for Jackson and Gson (can still be implemented through custom schema configurators)
|
||||||
|
|
||||||
|
## [3.14.4] - June 5th, 2023
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Components definitions were not in the proper schema section. Prefixed the path with component slug in `protobuf java converter`.
|
||||||
|
|
||||||
|
## [3.14.3] - May 22nd, 2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `required` parameter in request info builder.
|
||||||
|
|
||||||
|
## [3.14.2] - May 8rd, 2023
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Fixed bug where routes were not resolving when a parameter was declared via the ktor SDK
|
||||||
|
|
||||||
|
## [3.14.1] - April 28th, 2023
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Generating enrichments for generic classes no longer throws the `Slugs should not be generated for field enrichments` error.
|
||||||
|
|
||||||
|
## [3.14.0] - April 6th, 2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add support for response headers
|
||||||
|
|
||||||
|
## [3.13.0] - March 15th, 2023
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Post, Put, and Patch now support not providing request info
|
||||||
|
|
||||||
|
## [3.12.0] - March 14th, 2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add support for swagger documentation
|
||||||
|
|
||||||
|
## [3.11.0] - January 5th, 2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for type constraints.
|
||||||
|
|
||||||
|
## [3.10.0] - January 4th, 2023
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for type enrichments! `deprecated` and `description` to start
|
||||||
|
|
||||||
|
## [3.9.0] - November 15th, 2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `protobuf-java-converter` module for converting generated protobuf objects to `JsonSchema` representations
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Application `rootPath` is no longer prefixed to serialized route path when `NotarizedRoute` is resolved
|
||||||
|
|
||||||
|
## [3.8.0] - November 9th, 2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add support for NotarizedResource plugin scoped to route
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Support registering same path with different authentication and methods
|
||||||
|
|
||||||
|
## [3.7.0] - November 5th, 2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Allow users to override media type in request and response
|
||||||
|
|
||||||
|
## [3.6.0] - November 5th, 2022
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Schemas for types in nullable properties are no longer nullable themselves
|
||||||
|
- Enums are now generated as references, which makes it possible to generate types for them
|
||||||
|
|
||||||
|
## [3.5.0] - October 29th, 2022
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- New `kompendium-resources` plugin to support Ktor Resources API
|
||||||
|
|
||||||
## [3.4.0] - October 26th, 2022
|
## [3.4.0] - October 26th, 2022
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -3,3 +3,7 @@
|
|||||||
[](https://search.maven.org/search?q=io.bkbn%20kompendium)
|
[](https://search.maven.org/search?q=io.bkbn%20kompendium)
|
||||||
|
|
||||||
Documentation is stored in the `docs` folder and is hosted [here](https://bkbn.gitbook.io/kompendium)
|
Documentation is stored in the `docs` folder and is hosted [here](https://bkbn.gitbook.io/kompendium)
|
||||||
|
|
||||||
|
## Showcase
|
||||||
|
|
||||||
|
If you would like to showcase docs that you build using Kompendium, add them to [the showcase discussion](https://github.com/bkbnio/kompendium/discussions/444)
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
|
import com.vanniktech.maven.publish.SonatypeHost
|
||||||
|
import io.bkbn.sourdough.gradle.library.jvm.LibraryJvmPlugin
|
||||||
|
import io.bkbn.sourdough.gradle.library.jvm.LibraryJvmExtension
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.7.20" apply false
|
kotlin("jvm") version "2.0.21" apply false
|
||||||
kotlin("plugin.serialization") version "1.7.20" apply false
|
kotlin("plugin.serialization") version "2.0.21" apply false
|
||||||
id("io.bkbn.sourdough.library.jvm") version "0.12.0" apply false
|
id("io.bkbn.sourdough.library.jvm") version "0.13.1" apply false
|
||||||
id("io.bkbn.sourdough.application.jvm") version "0.12.0" apply false
|
id("io.bkbn.sourdough.application.jvm") version "0.13.1" apply false
|
||||||
id("io.bkbn.sourdough.root") version "0.12.0"
|
id("com.vanniktech.maven.publish") version "0.30.0" apply false
|
||||||
id("com.github.jakemarsden.git-hooks") version "0.0.2"
|
id("io.bkbn.sourdough.root") version "0.13.1"
|
||||||
id("org.jetbrains.kotlinx.kover") version "0.6.1"
|
id("org.jetbrains.kotlinx.kover") version "0.8.3"
|
||||||
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gitHooks {
|
dependencies {
|
||||||
setHooks(
|
subprojects.forEach { kover(it) }
|
||||||
mapOf(
|
|
||||||
"pre-commit" to "detekt",
|
|
||||||
"pre-push" to "test"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@ -31,15 +29,16 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
plugins.withType(io.bkbn.sourdough.gradle.library.jvm.LibraryJvmPlugin::class) {
|
plugins.withType(LibraryJvmPlugin::class) {
|
||||||
extensions.configure(io.bkbn.sourdough.gradle.library.jvm.LibraryJvmExtension::class) {
|
extensions.configure(LibraryJvmExtension::class) {
|
||||||
githubOrg.set("bkbnio")
|
githubOrg.set("bkbnio")
|
||||||
githubRepo.set("kompendium")
|
githubRepo.set("kompendium")
|
||||||
licenseName.set("MIT License")
|
licenseName.set("MIT License")
|
||||||
licenseUrl.set("https://mit-license.org")
|
licenseUrl.set("https://mit-license.org")
|
||||||
developerId.set("unredundant")
|
developerId.set("brizzbuzz")
|
||||||
developerName.set("Ryan Brink")
|
developerName.set("Ryan Brink")
|
||||||
developerEmail.set("admin@bkbn.io")
|
developerEmail.set("admin@bkbn.io")
|
||||||
|
sonatypeHost.set(SonatypeHost.CENTRAL_PORTAL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ plugins {
|
|||||||
id("io.bkbn.sourdough.library.jvm")
|
id("io.bkbn.sourdough.library.jvm")
|
||||||
id("io.gitlab.arturbosch.detekt")
|
id("io.gitlab.arturbosch.detekt")
|
||||||
id("com.adarshr.test-logger")
|
id("com.adarshr.test-logger")
|
||||||
id("maven-publish")
|
id("com.vanniktech.maven.publish")
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("signing")
|
id("signing")
|
||||||
id("java-test-fixtures")
|
id("java-test-fixtures")
|
||||||
@ -20,6 +20,7 @@ sourdoughLibrary {
|
|||||||
dependencies {
|
dependencies {
|
||||||
// VERSIONS
|
// VERSIONS
|
||||||
val kotestVersion: String by project
|
val kotestVersion: String by project
|
||||||
|
val kotlinSerializeVersion: String by project
|
||||||
val ktorVersion: String by project
|
val ktorVersion: String by project
|
||||||
val detektVersion: String by project
|
val detektVersion: String by project
|
||||||
|
|
||||||
@ -33,7 +34,6 @@ dependencies {
|
|||||||
implementation("io.ktor:ktor-server-html-builder:$ktorVersion")
|
implementation("io.ktor:ktor-server-html-builder:$ktorVersion")
|
||||||
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
||||||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
||||||
implementation("ch.qos.logback:logback-classic:1.4.4")
|
|
||||||
|
|
||||||
// Formatting
|
// Formatting
|
||||||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
|
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
|
||||||
@ -44,13 +44,11 @@ dependencies {
|
|||||||
testFixturesApi("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
|
testFixturesApi("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
|
||||||
testFixturesApi("io.kotest:kotest-property-jvm:$kotestVersion")
|
testFixturesApi("io.kotest:kotest-property-jvm:$kotestVersion")
|
||||||
testFixturesApi("io.kotest:kotest-assertions-json-jvm:$kotestVersion")
|
testFixturesApi("io.kotest:kotest-assertions-json-jvm:$kotestVersion")
|
||||||
testFixturesApi("io.kotest:kotest-assertions-ktor-jvm:4.4.3")
|
testFixturesApi("io.kotest.extensions:kotest-assertions-ktor:2.0.0")
|
||||||
|
|
||||||
testFixturesApi("io.ktor:ktor-server-core:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-server-core:$ktorVersion")
|
||||||
testFixturesApi("io.ktor:ktor-server-test-host:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-server-test-host:$ktorVersion")
|
||||||
testFixturesApi("io.ktor:ktor-serialization:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-serialization:$ktorVersion")
|
||||||
testFixturesApi("io.ktor:ktor-serialization-jackson:$ktorVersion")
|
|
||||||
testFixturesApi("io.ktor:ktor-serialization-gson:$ktorVersion")
|
|
||||||
testFixturesApi("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
||||||
testFixturesApi("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
||||||
testFixturesApi("io.ktor:ktor-server-auth:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-server-auth:$ktorVersion")
|
||||||
@ -58,9 +56,9 @@ dependencies {
|
|||||||
testFixturesApi("io.ktor:ktor-client:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-client:$ktorVersion")
|
||||||
testFixturesApi("io.ktor:ktor-client-cio:$ktorVersion")
|
testFixturesApi("io.ktor:ktor-client-cio:$ktorVersion")
|
||||||
|
|
||||||
testFixturesApi("dev.forst:ktor-api-key:2.1.2")
|
testFixturesApi("dev.forst:ktor-api-key:2.2.4")
|
||||||
|
|
||||||
testFixturesApi("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
|
testFixturesApi("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializeVersion")
|
||||||
}
|
}
|
||||||
|
|
||||||
testing {
|
testing {
|
||||||
|
@ -10,6 +10,7 @@ class DeleteInfo private constructor(
|
|||||||
override val summary: String,
|
override val summary: String,
|
||||||
override val description: String,
|
override val description: String,
|
||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
|
override val security: Map<String, List<String>>?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>
|
||||||
@ -33,7 +34,8 @@ class DeleteInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ class GetInfo private constructor(
|
|||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>,
|
||||||
|
override val security: Map<String, List<String>>?
|
||||||
) : MethodInfo {
|
) : MethodInfo {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -33,7 +34,8 @@ class GetInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ class HeadInfo private constructor(
|
|||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>,
|
||||||
|
override val security: Map<String, List<String>>?,
|
||||||
) : MethodInfo {
|
) : MethodInfo {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -33,7 +34,8 @@ class HeadInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ sealed interface MethodInfo {
|
|||||||
val tags: Set<String>
|
val tags: Set<String>
|
||||||
val summary: String
|
val summary: String
|
||||||
val description: String
|
val description: String
|
||||||
|
|
||||||
|
val security: Map<String, List<String>>?
|
||||||
|
get() = null
|
||||||
val externalDocumentation: ExternalDocumentation?
|
val externalDocumentation: ExternalDocumentation?
|
||||||
get() = null
|
get() = null
|
||||||
val operationId: String?
|
val operationId: String?
|
||||||
@ -28,6 +31,7 @@ sealed interface MethodInfo {
|
|||||||
internal var tags: Set<String> = emptySet()
|
internal var tags: Set<String> = emptySet()
|
||||||
internal var parameters: List<Parameter> = emptyList()
|
internal var parameters: List<Parameter> = emptyList()
|
||||||
internal var errors: MutableList<ResponseInfo> = mutableListOf()
|
internal var errors: MutableList<ResponseInfo> = mutableListOf()
|
||||||
|
internal var security: Map<String, List<String>>? = null
|
||||||
|
|
||||||
fun response(init: ResponseInfo.Builder.() -> Unit) = apply {
|
fun response(init: ResponseInfo.Builder.() -> Unit) = apply {
|
||||||
val builder = ResponseInfo.Builder()
|
val builder = ResponseInfo.Builder()
|
||||||
@ -59,6 +63,8 @@ sealed interface MethodInfo {
|
|||||||
|
|
||||||
fun parameters(vararg parameters: Parameter) = apply { this.parameters = parameters.toList() }
|
fun parameters(vararg parameters: Parameter) = apply { this.parameters = parameters.toList() }
|
||||||
|
|
||||||
|
fun security(security: Map<String, List<String>>) = apply { this.security = security }
|
||||||
|
|
||||||
abstract fun build(): T
|
abstract fun build(): T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.bkbn.kompendium.core.metadata
|
package io.bkbn.kompendium.core.metadata
|
||||||
|
|
||||||
sealed interface MethodInfoWithRequest : MethodInfo {
|
sealed interface MethodInfoWithRequest : MethodInfo {
|
||||||
val request: RequestInfo
|
val request: RequestInfo?
|
||||||
|
|
||||||
abstract class Builder<T : MethodInfoWithRequest> : MethodInfo.Builder<T>() {
|
abstract class Builder<T : MethodInfoWithRequest> : MethodInfo.Builder<T>() {
|
||||||
internal var request: RequestInfo? = null
|
internal var request: RequestInfo? = null
|
||||||
|
@ -12,7 +12,8 @@ class OptionsInfo private constructor(
|
|||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>,
|
||||||
|
override val security: Map<String, List<String>>?,
|
||||||
) : MethodInfo {
|
) : MethodInfo {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -33,7 +34,8 @@ class OptionsInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import io.bkbn.kompendium.oas.common.ExternalDocumentation
|
|||||||
import io.bkbn.kompendium.oas.payload.Parameter
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
|
||||||
class PatchInfo private constructor(
|
class PatchInfo private constructor(
|
||||||
override val request: RequestInfo,
|
override val request: RequestInfo?,
|
||||||
override val errors: MutableList<ResponseInfo>,
|
override val errors: MutableList<ResponseInfo>,
|
||||||
override val response: ResponseInfo,
|
override val response: ResponseInfo,
|
||||||
override val tags: Set<String>,
|
override val tags: Set<String>,
|
||||||
@ -13,7 +13,8 @@ class PatchInfo private constructor(
|
|||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>,
|
||||||
|
override val security: Map<String, List<String>>?,
|
||||||
) : MethodInfoWithRequest {
|
) : MethodInfoWithRequest {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -26,7 +27,7 @@ class PatchInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfoWithRequest.Builder<PatchInfo>() {
|
class Builder : MethodInfoWithRequest.Builder<PatchInfo>() {
|
||||||
override fun build() = PatchInfo(
|
override fun build() = PatchInfo(
|
||||||
request = request ?: error("request info must be present"),
|
request = request,
|
||||||
errors = errors,
|
errors = errors,
|
||||||
response = response ?: error("response info must be present"),
|
response = response ?: error("response info must be present"),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
@ -35,7 +36,8 @@ class PatchInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import io.bkbn.kompendium.oas.common.ExternalDocumentation
|
|||||||
import io.bkbn.kompendium.oas.payload.Parameter
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
|
||||||
class PostInfo private constructor(
|
class PostInfo private constructor(
|
||||||
override val request: RequestInfo,
|
override val request: RequestInfo?,
|
||||||
override val errors: MutableList<ResponseInfo>,
|
override val errors: MutableList<ResponseInfo>,
|
||||||
override val response: ResponseInfo,
|
override val response: ResponseInfo,
|
||||||
override val tags: Set<String>,
|
override val tags: Set<String>,
|
||||||
@ -13,7 +13,8 @@ class PostInfo private constructor(
|
|||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>,
|
||||||
|
override val security: Map<String, List<String>>?,
|
||||||
) : MethodInfoWithRequest {
|
) : MethodInfoWithRequest {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -26,7 +27,7 @@ class PostInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfoWithRequest.Builder<PostInfo>() {
|
class Builder : MethodInfoWithRequest.Builder<PostInfo>() {
|
||||||
override fun build() = PostInfo(
|
override fun build() = PostInfo(
|
||||||
request = request ?: error("request info must be present"),
|
request = request,
|
||||||
errors = errors,
|
errors = errors,
|
||||||
response = response ?: error("response info must be present"),
|
response = response ?: error("response info must be present"),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
@ -35,7 +36,8 @@ class PostInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import io.bkbn.kompendium.oas.common.ExternalDocumentation
|
|||||||
import io.bkbn.kompendium.oas.payload.Parameter
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
|
||||||
class PutInfo private constructor(
|
class PutInfo private constructor(
|
||||||
override val request: RequestInfo,
|
override val request: RequestInfo?,
|
||||||
override val errors: MutableList<ResponseInfo>,
|
override val errors: MutableList<ResponseInfo>,
|
||||||
override val response: ResponseInfo,
|
override val response: ResponseInfo,
|
||||||
override val tags: Set<String>,
|
override val tags: Set<String>,
|
||||||
@ -13,7 +13,8 @@ class PutInfo private constructor(
|
|||||||
override val externalDocumentation: ExternalDocumentation?,
|
override val externalDocumentation: ExternalDocumentation?,
|
||||||
override val operationId: String?,
|
override val operationId: String?,
|
||||||
override val deprecated: Boolean,
|
override val deprecated: Boolean,
|
||||||
override val parameters: List<Parameter>
|
override val parameters: List<Parameter>,
|
||||||
|
override val security: Map<String, List<String>>?,
|
||||||
) : MethodInfoWithRequest {
|
) : MethodInfoWithRequest {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -26,7 +27,7 @@ class PutInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfoWithRequest.Builder<PutInfo>() {
|
class Builder : MethodInfoWithRequest.Builder<PutInfo>() {
|
||||||
override fun build() = PutInfo(
|
override fun build() = PutInfo(
|
||||||
request = request ?: error("request info must be present"),
|
request = request,
|
||||||
errors = errors,
|
errors = errors,
|
||||||
response = response ?: error("response info must be present"),
|
response = response ?: error("response info must be present"),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
@ -35,7 +36,8 @@ class PutInfo private constructor(
|
|||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
parameters = parameters
|
parameters = parameters,
|
||||||
|
security = security,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package io.bkbn.kompendium.core.metadata
|
package io.bkbn.kompendium.core.metadata
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||||
import io.bkbn.kompendium.oas.payload.MediaType
|
import io.bkbn.kompendium.oas.payload.MediaType
|
||||||
import kotlin.reflect.KType
|
import kotlin.reflect.KType
|
||||||
import kotlin.reflect.typeOf
|
import kotlin.reflect.typeOf
|
||||||
|
|
||||||
class RequestInfo private constructor(
|
class RequestInfo private constructor(
|
||||||
val requestType: KType,
|
val requestType: KType,
|
||||||
|
val enrichment: TypeEnrichment<*>?,
|
||||||
val description: String,
|
val description: String,
|
||||||
val examples: Map<String, MediaType.Example>?
|
val examples: Map<String, MediaType.Example>?,
|
||||||
|
val mediaTypes: Set<String>,
|
||||||
|
val required: Boolean
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -20,25 +24,46 @@ class RequestInfo private constructor(
|
|||||||
|
|
||||||
class Builder {
|
class Builder {
|
||||||
private var requestType: KType? = null
|
private var requestType: KType? = null
|
||||||
|
private var typeEnrichment: TypeEnrichment<*>? = null
|
||||||
private var description: String? = null
|
private var description: String? = null
|
||||||
private var examples: Map<String, MediaType.Example>? = null
|
private var examples: Map<String, MediaType.Example>? = null
|
||||||
|
private var mediaTypes: Set<String>? = null
|
||||||
|
private var required: Boolean? = null
|
||||||
|
|
||||||
|
fun required(r: Boolean) = apply {
|
||||||
|
this.required = r
|
||||||
|
}
|
||||||
|
|
||||||
fun requestType(t: KType) = apply {
|
fun requestType(t: KType) = apply {
|
||||||
this.requestType = t
|
this.requestType = t
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T> requestType() = apply { requestType(typeOf<T>()) }
|
fun enrichment(t: TypeEnrichment<*>) = apply {
|
||||||
|
this.typeEnrichment = t
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> requestType(enrichment: TypeEnrichment<T>? = null) = apply {
|
||||||
|
requestType(typeOf<T>())
|
||||||
|
enrichment?.let { enrichment(it) }
|
||||||
|
}
|
||||||
|
|
||||||
fun description(s: String) = apply { this.description = s }
|
fun description(s: String) = apply { this.description = s }
|
||||||
|
|
||||||
fun examples(vararg e: Pair<String, Any>) = apply {
|
fun examples(vararg e: Pair<String, MediaType.Example>) = apply {
|
||||||
this.examples = e.toMap().mapValues { (_, v) -> MediaType.Example(v) }
|
this.examples = e.toMap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun mediaTypes(vararg m: String) = apply {
|
||||||
|
this.mediaTypes = m.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build() = RequestInfo(
|
fun build() = RequestInfo(
|
||||||
requestType = requestType ?: error("Request type must be present"),
|
requestType = requestType ?: error("Request type must be present"),
|
||||||
description = description ?: error("Description must be present"),
|
description = description ?: error("Description must be present"),
|
||||||
examples = examples
|
enrichment = typeEnrichment,
|
||||||
|
examples = examples,
|
||||||
|
mediaTypes = mediaTypes ?: setOf("application/json"),
|
||||||
|
required = required ?: true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package io.bkbn.kompendium.core.metadata
|
package io.bkbn.kompendium.core.metadata
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||||
|
import io.bkbn.kompendium.oas.payload.Header
|
||||||
import io.bkbn.kompendium.oas.payload.MediaType
|
import io.bkbn.kompendium.oas.payload.MediaType
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import kotlin.reflect.KType
|
import kotlin.reflect.KType
|
||||||
@ -8,8 +10,11 @@ import kotlin.reflect.typeOf
|
|||||||
class ResponseInfo private constructor(
|
class ResponseInfo private constructor(
|
||||||
val responseCode: HttpStatusCode,
|
val responseCode: HttpStatusCode,
|
||||||
val responseType: KType,
|
val responseType: KType,
|
||||||
|
val enrichment: TypeEnrichment<*>?,
|
||||||
val description: String,
|
val description: String,
|
||||||
val examples: Map<String, MediaType.Example>?
|
val examples: Map<String, MediaType.Example>?,
|
||||||
|
val mediaTypes: Set<String>,
|
||||||
|
val responseHeaders: Map<String, Header>?
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -23,8 +28,15 @@ class ResponseInfo private constructor(
|
|||||||
class Builder {
|
class Builder {
|
||||||
private var responseCode: HttpStatusCode? = null
|
private var responseCode: HttpStatusCode? = null
|
||||||
private var responseType: KType? = null
|
private var responseType: KType? = null
|
||||||
|
private var typeEnrichment: TypeEnrichment<*>? = null
|
||||||
private var description: String? = null
|
private var description: String? = null
|
||||||
private var examples: Map<String, MediaType.Example>? = null
|
private var examples: Map<String, MediaType.Example>? = null
|
||||||
|
private var mediaTypes: Set<String>? = null
|
||||||
|
private var responseHeaders: Map<String, Header>? = null
|
||||||
|
|
||||||
|
fun responseHeaders(headers: Map<String, Header>) = apply {
|
||||||
|
this.responseHeaders = headers
|
||||||
|
}
|
||||||
|
|
||||||
fun responseCode(code: HttpStatusCode) = apply {
|
fun responseCode(code: HttpStatusCode) = apply {
|
||||||
this.responseCode = code
|
this.responseCode = code
|
||||||
@ -34,19 +46,33 @@ class ResponseInfo private constructor(
|
|||||||
this.responseType = t
|
this.responseType = t
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T> responseType() = apply { responseType(typeOf<T>()) }
|
fun enrichment(t: TypeEnrichment<*>) = apply {
|
||||||
|
this.typeEnrichment = t
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> responseType(enrichment: TypeEnrichment<T>? = null) = apply {
|
||||||
|
responseType(typeOf<T>())
|
||||||
|
enrichment?.let { enrichment(it) }
|
||||||
|
}
|
||||||
|
|
||||||
fun description(s: String) = apply { this.description = s }
|
fun description(s: String) = apply { this.description = s }
|
||||||
|
|
||||||
fun examples(vararg e: Pair<String, Any>) = apply {
|
fun examples(vararg e: Pair<String, MediaType.Example>) = apply {
|
||||||
this.examples = e.toMap().mapValues { (_, v) -> MediaType.Example(v) }
|
this.examples = e.toMap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun mediaTypes(vararg m: String) = apply {
|
||||||
|
this.mediaTypes = m.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build() = ResponseInfo(
|
fun build() = ResponseInfo(
|
||||||
responseCode = responseCode ?: error("You must provide a response code in order to build a Response!"),
|
responseCode = responseCode ?: error("You must provide a response code in order to build a Response!"),
|
||||||
responseType = responseType ?: error("You must provide a response type in order to build a Response!"),
|
responseType = responseType ?: error("You must provide a response type in order to build a Response!"),
|
||||||
description = description ?: error("You must provide a description in order to build a Response!"),
|
description = description ?: error("You must provide a description in order to build a Response!"),
|
||||||
examples = examples
|
enrichment = typeEnrichment,
|
||||||
|
examples = examples,
|
||||||
|
mediaTypes = mediaTypes ?: setOf("application/json"),
|
||||||
|
responseHeaders = responseHeaders
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package io.bkbn.kompendium.core.plugin
|
package io.bkbn.kompendium.core.plugin
|
||||||
|
|
||||||
import io.bkbn.kompendium.core.attribute.KompendiumAttributes
|
import io.bkbn.kompendium.core.attribute.KompendiumAttributes
|
||||||
|
import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator
|
||||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
||||||
import io.bkbn.kompendium.oas.OpenApiSpec
|
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||||
import io.ktor.http.HttpStatusCode
|
|
||||||
import io.ktor.server.application.call
|
|
||||||
import io.ktor.server.application.createApplicationPlugin
|
import io.ktor.server.application.createApplicationPlugin
|
||||||
import io.ktor.server.response.respond
|
import io.ktor.server.response.respond
|
||||||
import io.ktor.server.routing.Routing
|
import io.ktor.server.routing.Routing
|
||||||
import io.ktor.server.routing.application
|
|
||||||
import io.ktor.server.routing.get
|
import io.ktor.server.routing.get
|
||||||
import io.ktor.server.routing.route
|
import io.ktor.server.routing.route
|
||||||
import io.ktor.server.routing.routing
|
import io.ktor.server.routing.routing
|
||||||
@ -19,25 +17,26 @@ import kotlin.reflect.KType
|
|||||||
object NotarizedApplication {
|
object NotarizedApplication {
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
lateinit var spec: OpenApiSpec
|
lateinit var spec: () -> OpenApiSpec
|
||||||
var openApiJson: Routing.() -> Unit = {
|
var specRoute: (OpenApiSpec, Routing) -> Unit = { spec, routing ->
|
||||||
route("/openapi.json") {
|
routing.route("/openapi.json") {
|
||||||
get {
|
get {
|
||||||
call.respond(HttpStatusCode.OK, this@route.application.attributes[KompendiumAttributes.openApiSpec])
|
call.respond(spec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var customTypes: Map<KType, JsonSchema> = emptyMap()
|
var customTypes: Map<KType, JsonSchema> = emptyMap()
|
||||||
var schemaConfigurator: SchemaConfigurator = SchemaConfigurator.Default()
|
var schemaConfigurator: SchemaConfigurator = KotlinXSchemaConfigurator()
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun invoke() = createApplicationPlugin(
|
operator fun invoke() = createApplicationPlugin(
|
||||||
name = "NotarizedApplication",
|
name = "NotarizedApplication",
|
||||||
createConfiguration = ::Config
|
createConfiguration = ::Config
|
||||||
) {
|
) {
|
||||||
val spec = pluginConfig.spec
|
val spec = pluginConfig.spec()
|
||||||
val routing = application.routing {}
|
val routing = application.routing {}
|
||||||
pluginConfig.openApiJson(routing)
|
this@createApplicationPlugin.pluginConfig.specRoute(spec, routing)
|
||||||
|
// pluginConfig.openApiJson(routing)
|
||||||
pluginConfig.customTypes.forEach { (type, schema) ->
|
pluginConfig.customTypes.forEach { (type, schema) ->
|
||||||
spec.components.schemas[type.getSimpleSlug()] = schema
|
spec.components.schemas[type.getSimpleSlug()] = schema
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,17 @@ import io.bkbn.kompendium.core.metadata.PostInfo
|
|||||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||||
import io.bkbn.kompendium.core.util.Helpers.addToSpec
|
import io.bkbn.kompendium.core.util.Helpers.addToSpec
|
||||||
import io.bkbn.kompendium.core.util.SpecConfig
|
import io.bkbn.kompendium.core.util.SpecConfig
|
||||||
|
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||||
import io.bkbn.kompendium.oas.path.Path
|
import io.bkbn.kompendium.oas.path.Path
|
||||||
import io.bkbn.kompendium.oas.path.PathOperation
|
|
||||||
import io.bkbn.kompendium.oas.payload.Parameter
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
import io.ktor.server.application.ApplicationCallPipeline
|
import io.ktor.server.application.ApplicationCallPipeline
|
||||||
import io.ktor.server.application.Hook
|
import io.ktor.server.application.Hook
|
||||||
|
import io.ktor.server.application.PluginBuilder
|
||||||
import io.ktor.server.application.createRouteScopedPlugin
|
import io.ktor.server.application.createRouteScopedPlugin
|
||||||
import io.ktor.server.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.application
|
||||||
|
|
||||||
object NotarizedRoute {
|
object NotarizedRoute {
|
||||||
|
|
||||||
class Config : SpecConfig {
|
class Config : SpecConfig {
|
||||||
override var tags: Set<String> = emptySet()
|
override var tags: Set<String> = emptySet()
|
||||||
override var parameters: List<Parameter> = emptyList()
|
override var parameters: List<Parameter> = emptyList()
|
||||||
@ -31,7 +32,6 @@ object NotarizedRoute {
|
|||||||
override var head: HeadInfo? = null
|
override var head: HeadInfo? = null
|
||||||
override var options: OptionsInfo? = null
|
override var options: OptionsInfo? = null
|
||||||
override var security: Map<String, List<String>>? = null
|
override var security: Map<String, List<String>>? = null
|
||||||
internal var path: Path? = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private object InstallHook : Hook<(ApplicationCallPipeline) -> Unit> {
|
private object InstallHook : Hook<(ApplicationCallPipeline) -> Unit> {
|
||||||
@ -44,69 +44,54 @@ object NotarizedRoute {
|
|||||||
name = "NotarizedRoute",
|
name = "NotarizedRoute",
|
||||||
createConfiguration = ::Config
|
createConfiguration = ::Config
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// This is required in order to introspect the route path and authentication
|
// This is required in order to introspect the route path and authentication
|
||||||
on(InstallHook) {
|
on(InstallHook) {
|
||||||
val route = it as? Route ?: return@on
|
val route = it as? Route ?: return@on
|
||||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||||
val routePath = route.calculateRoutePath()
|
val routePath = route.calculateRoutePath()
|
||||||
val authMethods = route.collectAuthMethods()
|
val authMethods = route.collectAuthMethods()
|
||||||
pluginConfig.path?.addDefaultAuthMethods(authMethods)
|
|
||||||
require(spec.paths[routePath] == null) {
|
addToSpec(spec, routePath, authMethods)
|
||||||
"""
|
|
||||||
The specified path ${Parameter.Location.path} has already been documented!
|
|
||||||
Please make sure that all notarized paths are unique
|
|
||||||
""".trimIndent()
|
|
||||||
}
|
}
|
||||||
spec.paths[routePath] = pluginConfig.path
|
|
||||||
?: error("This indicates a bug in Kompendium. Please file a GitHub issue!")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
fun <T : SpecConfig> PluginBuilder<T>.addToSpec(
|
||||||
|
spec: OpenApiSpec,
|
||||||
|
fullPath: String,
|
||||||
|
authMethods: List<String>
|
||||||
|
) {
|
||||||
|
val path = spec.paths[fullPath] ?: Path()
|
||||||
|
|
||||||
|
path.parameters = path.parameters?.plus(pluginConfig.parameters) ?: pluginConfig.parameters
|
||||||
val serializableReader = application.attributes[KompendiumAttributes.schemaConfigurator]
|
val serializableReader = application.attributes[KompendiumAttributes.schemaConfigurator]
|
||||||
|
|
||||||
val path = Path()
|
pluginConfig.get?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
path.parameters = pluginConfig.parameters
|
pluginConfig.delete?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
|
pluginConfig.head?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
|
pluginConfig.options?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
|
pluginConfig.post?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
|
pluginConfig.put?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
|
pluginConfig.patch?.addToSpec(path, spec, pluginConfig, serializableReader, fullPath, authMethods)
|
||||||
|
|
||||||
pluginConfig.get?.addToSpec(path, spec, pluginConfig, serializableReader)
|
spec.paths[fullPath] = path
|
||||||
pluginConfig.delete?.addToSpec(path, spec, pluginConfig, serializableReader)
|
|
||||||
pluginConfig.head?.addToSpec(path, spec, pluginConfig, serializableReader)
|
|
||||||
pluginConfig.options?.addToSpec(path, spec, pluginConfig, serializableReader)
|
|
||||||
pluginConfig.post?.addToSpec(path, spec, pluginConfig, serializableReader)
|
|
||||||
pluginConfig.put?.addToSpec(path, spec, pluginConfig, serializableReader)
|
|
||||||
pluginConfig.patch?.addToSpec(path, spec, pluginConfig, serializableReader)
|
|
||||||
|
|
||||||
pluginConfig.path = path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Route.calculateRoutePath() = toString().replace(Regex("/\\(.+\\)"), "")
|
fun Route.calculateRoutePath() = toString()
|
||||||
private fun Route.collectAuthMethods() = toString()
|
.let {
|
||||||
|
application.rootPath.takeIf { root -> root.isNotEmpty() }
|
||||||
|
?.let { root ->
|
||||||
|
val sanitizedRoute = if (root.startsWith("/")) root else "/$root"
|
||||||
|
it.replace(sanitizedRoute, "")
|
||||||
|
}
|
||||||
|
?: it
|
||||||
|
}
|
||||||
|
.replace(Regex("/\\(.+\\)"), "")
|
||||||
|
.replace(Regex("/\\[.+\\]"), "")
|
||||||
|
|
||||||
|
fun Route.collectAuthMethods() = toString()
|
||||||
.split("/")
|
.split("/")
|
||||||
.filter { it.contains(Regex("\\(authenticate .*\\)")) }
|
.filter { it.contains(Regex("\\(authenticate .*\\)")) }
|
||||||
.map { it.replace("(authenticate ", "").replace(")", "") }
|
.map { it.replace("(authenticate ", "").replace(")", "") }
|
||||||
.map { it.split(", ") }
|
.map { it.split(", ") }
|
||||||
.flatten()
|
.flatten()
|
||||||
|
|
||||||
private fun Path.addDefaultAuthMethods(methods: List<String>) {
|
|
||||||
get?.addDefaultAuthMethods(methods)
|
|
||||||
put?.addDefaultAuthMethods(methods)
|
|
||||||
post?.addDefaultAuthMethods(methods)
|
|
||||||
delete?.addDefaultAuthMethods(methods)
|
|
||||||
options?.addDefaultAuthMethods(methods)
|
|
||||||
head?.addDefaultAuthMethods(methods)
|
|
||||||
patch?.addDefaultAuthMethods(methods)
|
|
||||||
trace?.addDefaultAuthMethods(methods)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun PathOperation.addDefaultAuthMethods(methods: List<String>) {
|
|
||||||
methods.forEach { m ->
|
|
||||||
if (security == null || security?.all { s -> !s.containsKey(m) } == true) {
|
|
||||||
if (security == null) {
|
|
||||||
security = mutableListOf(mapOf(m to emptyList()))
|
|
||||||
} else {
|
|
||||||
security?.add(mapOf(m to emptyList()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import kotlinx.html.unsafe
|
|||||||
/**
|
/**
|
||||||
* Provides an out-of-the-box route to view docs using ReDoc on the specified [path].
|
* Provides an out-of-the-box route to view docs using ReDoc on the specified [path].
|
||||||
* @param pageTitle Webpage title you wish to be displayed on your docs
|
* @param pageTitle Webpage title you wish to be displayed on your docs
|
||||||
* @param route path to docs resource
|
* @param path path to docs resource
|
||||||
* @param specUrl url to point ReDoc to the OpenAPI json document
|
* @param specUrl url to point ReDoc to the OpenAPI json document
|
||||||
*/
|
*/
|
||||||
fun Route.redoc(pageTitle: String = "Docs", path: String = "/docs", specUrl: String = "/openapi.json") {
|
fun Route.redoc(pageTitle: String = "Docs", path: String = "/docs", specUrl: String = "/openapi.json") {
|
||||||
|
@ -0,0 +1,91 @@
|
|||||||
|
package io.bkbn.kompendium.core.routes
|
||||||
|
|
||||||
|
import io.ktor.server.application.call
|
||||||
|
import io.ktor.server.html.respondHtml
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
import kotlinx.html.body
|
||||||
|
import kotlinx.html.div
|
||||||
|
import kotlinx.html.head
|
||||||
|
import kotlinx.html.id
|
||||||
|
import kotlinx.html.link
|
||||||
|
import kotlinx.html.meta
|
||||||
|
import kotlinx.html.script
|
||||||
|
import kotlinx.html.title
|
||||||
|
import kotlinx.html.unsafe
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an out-of-the-box route to view docs using Swagger
|
||||||
|
* @see <a href="https://swagger.io/specification/">Swagger OpenApi Specification</a>
|
||||||
|
* for the latest supported open api version.
|
||||||
|
* @param pageTitle Webpage title you wish to be displayed on your docs
|
||||||
|
* @param path path to docs resource
|
||||||
|
* @param specUrl url to point Swagger to the OpenAPI json document
|
||||||
|
* @param swaggerVersion version of swagger-ui distribution
|
||||||
|
*/
|
||||||
|
fun Route.swagger(
|
||||||
|
pageTitle: String = "Docs",
|
||||||
|
path: String = "/swagger-ui",
|
||||||
|
specUrl: String = "/openapi.json",
|
||||||
|
swaggerVersion: String? = null
|
||||||
|
) {
|
||||||
|
val swaggerVersionSuffix = if (swaggerVersion == null) "" else "@$swaggerVersion"
|
||||||
|
|
||||||
|
route(path) {
|
||||||
|
get {
|
||||||
|
call.respondHtml {
|
||||||
|
head {
|
||||||
|
title {
|
||||||
|
+pageTitle
|
||||||
|
}
|
||||||
|
meta {
|
||||||
|
charset = "utf-8"
|
||||||
|
}
|
||||||
|
meta {
|
||||||
|
name = "viewport"
|
||||||
|
content = "width=device-width, initial-scale=1"
|
||||||
|
}
|
||||||
|
link {
|
||||||
|
href = "https://unpkg.com/swagger-ui-dist$swaggerVersionSuffix/swagger-ui.css"
|
||||||
|
rel = "stylesheet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
div {
|
||||||
|
id = "swagger-ui"
|
||||||
|
}
|
||||||
|
script {
|
||||||
|
src = "https://unpkg.com/swagger-ui-dist$swaggerVersionSuffix/swagger-ui-standalone-preset.js"
|
||||||
|
}
|
||||||
|
script {
|
||||||
|
src = "https://unpkg.com/swagger-ui-dist$swaggerVersionSuffix/swagger-ui-bundle.js"
|
||||||
|
}
|
||||||
|
unsafe {
|
||||||
|
+"""
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
// Build a system
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
url: "$specUrl",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
deepLinking: true,
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout",
|
||||||
|
})
|
||||||
|
window.ui = ui
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,11 +10,14 @@ import io.bkbn.kompendium.core.metadata.PatchInfo
|
|||||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||||
import io.bkbn.kompendium.core.metadata.ResponseInfo
|
import io.bkbn.kompendium.core.metadata.ResponseInfo
|
||||||
|
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
||||||
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
import io.bkbn.kompendium.json.schema.SchemaGenerator
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.NullableDefinition
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.OneOfDefinition
|
||||||
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
import io.bkbn.kompendium.json.schema.definition.ReferenceDefinition
|
||||||
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
import io.bkbn.kompendium.json.schema.util.Helpers.getReferenceSlug
|
||||||
import io.bkbn.kompendium.json.schema.util.Helpers.getSimpleSlug
|
import io.bkbn.kompendium.json.schema.util.Helpers.getSlug
|
||||||
import io.bkbn.kompendium.oas.OpenApiSpec
|
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||||
import io.bkbn.kompendium.oas.path.Path
|
import io.bkbn.kompendium.oas.path.Path
|
||||||
import io.bkbn.kompendium.oas.path.PathOperation
|
import io.bkbn.kompendium.oas.path.PathOperation
|
||||||
@ -22,32 +25,72 @@ import io.bkbn.kompendium.oas.payload.MediaType
|
|||||||
import io.bkbn.kompendium.oas.payload.Request
|
import io.bkbn.kompendium.oas.payload.Request
|
||||||
import io.bkbn.kompendium.oas.payload.Response
|
import io.bkbn.kompendium.oas.payload.Response
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
import kotlin.reflect.KMutableProperty1
|
||||||
import kotlin.reflect.KType
|
import kotlin.reflect.KType
|
||||||
|
|
||||||
object Helpers {
|
object Helpers {
|
||||||
|
|
||||||
fun MethodInfo.addToSpec(path: Path, spec: OpenApiSpec, config: SpecConfig, schemaConfigurator: SchemaConfigurator) {
|
private fun PathOperation.addDefaultAuthMethods(methods: List<String>) {
|
||||||
|
methods.forEach { m ->
|
||||||
|
if (security == null || security?.all { s -> !s.containsKey(m) } == true) {
|
||||||
|
if (security == null) {
|
||||||
|
security = mutableListOf(mapOf(m to emptyList()))
|
||||||
|
} else {
|
||||||
|
security?.add(mapOf(m to emptyList()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("CyclomaticComplexMethod")
|
||||||
|
fun MethodInfo.addToSpec(
|
||||||
|
path: Path,
|
||||||
|
spec: OpenApiSpec,
|
||||||
|
config: SpecConfig,
|
||||||
|
schemaConfigurator: SchemaConfigurator,
|
||||||
|
routePath: String,
|
||||||
|
authMethods: List<String> = emptyList()
|
||||||
|
) {
|
||||||
|
val type = this.response.responseType
|
||||||
|
val enrichment = this.response.enrichment
|
||||||
SchemaGenerator.fromTypeOrUnit(
|
SchemaGenerator.fromTypeOrUnit(
|
||||||
this.response.responseType,
|
type = type,
|
||||||
spec.components.schemas, schemaConfigurator
|
cache = spec.components.schemas,
|
||||||
|
schemaConfigurator = schemaConfigurator,
|
||||||
|
enrichment = enrichment,
|
||||||
)?.let { schema ->
|
)?.let { schema ->
|
||||||
spec.components.schemas[this.response.responseType.getSimpleSlug()] = schema
|
val slug = type.getSlug(enrichment)
|
||||||
|
spec.components.schemas[slug] = schema
|
||||||
}
|
}
|
||||||
|
|
||||||
errors.forEach { error ->
|
errors.forEach { error ->
|
||||||
SchemaGenerator.fromTypeOrUnit(error.responseType, spec.components.schemas, schemaConfigurator)?.let { schema ->
|
val errorEnrichment = error.enrichment
|
||||||
spec.components.schemas[error.responseType.getSimpleSlug()] = schema
|
val errorType = error.responseType
|
||||||
|
SchemaGenerator.fromTypeOrUnit(
|
||||||
|
type = errorType,
|
||||||
|
cache = spec.components.schemas,
|
||||||
|
schemaConfigurator = schemaConfigurator,
|
||||||
|
enrichment = errorEnrichment,
|
||||||
|
)?.let { schema ->
|
||||||
|
val slug = errorType.getSlug(errorEnrichment)
|
||||||
|
spec.components.schemas[slug] = schema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when (this) {
|
when (this) {
|
||||||
is MethodInfoWithRequest -> {
|
is MethodInfoWithRequest -> {
|
||||||
|
this.request?.let { reqInfo ->
|
||||||
|
val reqEnrichment = reqInfo.enrichment
|
||||||
|
val reqType = reqInfo.requestType
|
||||||
SchemaGenerator.fromTypeOrUnit(
|
SchemaGenerator.fromTypeOrUnit(
|
||||||
this.request.requestType,
|
type = reqType,
|
||||||
spec.components.schemas,
|
cache = spec.components.schemas,
|
||||||
schemaConfigurator
|
schemaConfigurator = schemaConfigurator,
|
||||||
|
enrichment = reqEnrichment,
|
||||||
)?.let { schema ->
|
)?.let { schema ->
|
||||||
spec.components.schemas[this.request.requestType.getSimpleSlug()] = schema
|
val slug = reqType.getSlug(reqEnrichment)
|
||||||
|
spec.components.schemas[slug] = schema
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +98,25 @@ object Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val operations = this.toPathOperation(config)
|
val operations = this.toPathOperation(config)
|
||||||
|
operations.addDefaultAuthMethods(authMethods)
|
||||||
|
|
||||||
when (this) {
|
fun setOperation(
|
||||||
is DeleteInfo -> path.delete = operations
|
property: KMutableProperty1<Path, PathOperation?>
|
||||||
is GetInfo -> path.get = operations
|
) {
|
||||||
is HeadInfo -> path.head = operations
|
require(property.get(path) == null) {
|
||||||
is PatchInfo -> path.patch = operations
|
"A route has already been registered for path: $routePath and method: ${property.name.uppercase()}"
|
||||||
is PostInfo -> path.post = operations
|
}
|
||||||
is PutInfo -> path.put = operations
|
property.set(path, operations)
|
||||||
is OptionsInfo -> path.options = operations
|
}
|
||||||
|
|
||||||
|
return when (this) {
|
||||||
|
is DeleteInfo -> setOperation(Path::delete)
|
||||||
|
is GetInfo -> setOperation(Path::get)
|
||||||
|
is HeadInfo -> setOperation(Path::head)
|
||||||
|
is PatchInfo -> setOperation(Path::patch)
|
||||||
|
is PostInfo -> setOperation(Path::post)
|
||||||
|
is PutInfo -> setOperation(Path::put)
|
||||||
|
is OptionsInfo -> setOperation(Path::options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,42 +128,85 @@ object Helpers {
|
|||||||
operationId = this.operationId,
|
operationId = this.operationId,
|
||||||
deprecated = this.deprecated,
|
deprecated = this.deprecated,
|
||||||
parameters = this.parameters,
|
parameters = this.parameters,
|
||||||
security = config.security
|
security = this.createCombinedSecurityContext(config),
|
||||||
?.map { (k, v) -> k to v }
|
|
||||||
?.map { listOf(it).toMap() }
|
|
||||||
?.toMutableList(),
|
|
||||||
requestBody = when (this) {
|
requestBody = when (this) {
|
||||||
is MethodInfoWithRequest -> Request(
|
is MethodInfoWithRequest -> this.request?.let { reqInfo ->
|
||||||
description = this.request.description,
|
Request(
|
||||||
content = this.request.requestType.toReferenceContent(this.request.examples),
|
description = reqInfo.description,
|
||||||
required = true
|
content = reqInfo.requestType.toReferenceContent(
|
||||||
|
examples = reqInfo.examples,
|
||||||
|
mediaTypes = reqInfo.mediaTypes,
|
||||||
|
enrichment = reqInfo.enrichment
|
||||||
|
),
|
||||||
|
required = reqInfo.required
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
},
|
},
|
||||||
responses = mapOf(
|
responses = mapOf(
|
||||||
this.response.responseCode.value to Response(
|
this.response.responseCode.value to Response(
|
||||||
description = this.response.description,
|
description = this.response.description,
|
||||||
content = this.response.responseType.toReferenceContent(this.response.examples)
|
headers = this.response.responseHeaders,
|
||||||
|
content = this.response.responseType.toReferenceContent(
|
||||||
|
examples = this.response.examples,
|
||||||
|
mediaTypes = this.response.mediaTypes,
|
||||||
|
enrichment = this.response.enrichment
|
||||||
|
)
|
||||||
)
|
)
|
||||||
).plus(this.errors.toResponseMap())
|
).plus(this.errors.toResponseMap())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun MethodInfo.createCombinedSecurityContext(config: SpecConfig): MutableList<Map<String, List<String>>>? {
|
||||||
|
val configSecurity = config.security
|
||||||
|
?.map { (k, v) -> k to v }
|
||||||
|
?.map { listOf(it).toMap() }
|
||||||
|
?.toMutableList()
|
||||||
|
|
||||||
|
val methodSecurity = this.security
|
||||||
|
?.map { (k, v) -> k to v }
|
||||||
|
?.map { listOf(it).toMap() }
|
||||||
|
?.toMutableList()
|
||||||
|
|
||||||
|
return when {
|
||||||
|
configSecurity == null && methodSecurity == null -> null
|
||||||
|
configSecurity == null -> methodSecurity
|
||||||
|
methodSecurity == null -> configSecurity
|
||||||
|
else -> configSecurity.plus(methodSecurity).toMutableList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun List<ResponseInfo>.toResponseMap(): Map<Int, Response> = associate { error ->
|
private fun List<ResponseInfo>.toResponseMap(): Map<Int, Response> = associate { error ->
|
||||||
error.responseCode.value to Response(
|
error.responseCode.value to Response(
|
||||||
description = error.description,
|
description = error.description,
|
||||||
content = error.responseType.toReferenceContent(error.examples)
|
headers = error.responseHeaders,
|
||||||
|
content = error.responseType.toReferenceContent(
|
||||||
|
examples = error.examples,
|
||||||
|
mediaTypes = error.mediaTypes,
|
||||||
|
enrichment = error.enrichment
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KType.toReferenceContent(examples: Map<String, MediaType.Example>?): Map<String, MediaType>? =
|
private fun KType.toReferenceContent(
|
||||||
|
examples: Map<String, MediaType.Example>?,
|
||||||
|
mediaTypes: Set<String>,
|
||||||
|
enrichment: TypeEnrichment<*>?
|
||||||
|
): Map<String, MediaType>? =
|
||||||
when (this.classifier as KClass<*>) {
|
when (this.classifier as KClass<*>) {
|
||||||
Unit::class -> null
|
Unit::class -> null
|
||||||
else -> mapOf(
|
else -> mediaTypes.associateWith {
|
||||||
"application/json" to MediaType(
|
MediaType(
|
||||||
schema = ReferenceDefinition(this.getReferenceSlug()),
|
schema = if (this.isMarkedNullable) {
|
||||||
|
OneOfDefinition(
|
||||||
|
NullableDefinition(),
|
||||||
|
ReferenceDefinition(this.getReferenceSlug(enrichment))
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ReferenceDefinition(this.getReferenceSlug(enrichment))
|
||||||
|
},
|
||||||
examples = examples
|
examples = examples
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,172 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import dev.forst.ktor.apikey.apiKey
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.customAuthConfig
|
||||||
|
import io.bkbn.kompendium.core.util.customScopesOnSiblingPathOperations
|
||||||
|
import io.bkbn.kompendium.core.util.defaultAuthConfig
|
||||||
|
import io.bkbn.kompendium.core.util.multipleAuthStrategies
|
||||||
|
import io.bkbn.kompendium.oas.component.Components
|
||||||
|
import io.bkbn.kompendium.oas.security.ApiKeyAuth
|
||||||
|
import io.bkbn.kompendium.oas.security.BasicAuth
|
||||||
|
import io.bkbn.kompendium.oas.security.BearerAuth
|
||||||
|
import io.bkbn.kompendium.oas.security.OAuth
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.engine.cio.CIO
|
||||||
|
import io.ktor.http.HttpMethod
|
||||||
|
import io.ktor.server.application.install
|
||||||
|
import io.ktor.server.auth.Authentication
|
||||||
|
import io.ktor.server.auth.OAuthServerSettings
|
||||||
|
import io.ktor.server.auth.Principal
|
||||||
|
import io.ktor.server.auth.UserIdPrincipal
|
||||||
|
import io.ktor.server.auth.basic
|
||||||
|
import io.ktor.server.auth.jwt.jwt
|
||||||
|
import io.ktor.server.auth.oauth
|
||||||
|
|
||||||
|
class KompendiumAuthenticationTest : DescribeSpec({
|
||||||
|
describe("Authentication") {
|
||||||
|
it("Can add a default auth config by default") {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
snapshotName = "T0045__default_auth_config.json",
|
||||||
|
applicationSetup = {
|
||||||
|
install(Authentication) {
|
||||||
|
basic("basic") {
|
||||||
|
realm = "Ktor Server"
|
||||||
|
validate { UserIdPrincipal("Placeholder") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
specOverrides = {
|
||||||
|
this.copy(
|
||||||
|
components = Components(
|
||||||
|
securitySchemes = mutableMapOf(
|
||||||
|
"basic" to BasicAuth()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { defaultAuthConfig() }
|
||||||
|
}
|
||||||
|
it("Can provide custom auth config with proper scopes") {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
snapshotName = "T0046__custom_auth_config.json",
|
||||||
|
applicationSetup = {
|
||||||
|
install(Authentication) {
|
||||||
|
oauth("auth-oauth-google") {
|
||||||
|
urlProvider = { "http://localhost:8080/callback" }
|
||||||
|
providerLookup = {
|
||||||
|
OAuthServerSettings.OAuth2ServerSettings(
|
||||||
|
name = "google",
|
||||||
|
authorizeUrl = "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
accessTokenUrl = "https://accounts.google.com/o/oauth2/token",
|
||||||
|
requestMethod = HttpMethod.Post,
|
||||||
|
clientId = "DUMMY_VAL",
|
||||||
|
clientSecret = "DUMMY_VAL",
|
||||||
|
defaultScopes = listOf("https://www.googleapis.com/auth/userinfo.profile"),
|
||||||
|
extraTokenParameters = listOf("access_type" to "offline")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
client = HttpClient(CIO)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
specOverrides = {
|
||||||
|
this.copy(
|
||||||
|
components = Components(
|
||||||
|
securitySchemes = mutableMapOf(
|
||||||
|
"auth-oauth-google" to OAuth(
|
||||||
|
flows = OAuth.Flows(
|
||||||
|
implicit = OAuth.Flows.Implicit(
|
||||||
|
authorizationUrl = "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
scopes = mapOf(
|
||||||
|
"write:pets" to "modify pets in your account",
|
||||||
|
"read:pets" to "read your pets"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { customAuthConfig() }
|
||||||
|
}
|
||||||
|
it("Can provide multiple authentication strategies") {
|
||||||
|
data class TestAppPrincipal(val key: String) : Principal
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
snapshotName = "T0047__multiple_auth_strategies.json",
|
||||||
|
applicationSetup = {
|
||||||
|
install(Authentication) {
|
||||||
|
apiKey("api-key") {
|
||||||
|
headerName = "X-API-KEY"
|
||||||
|
validate { key ->
|
||||||
|
// api key library (dev.forst.ktor.apikey) is using the deprecated `Principal` class
|
||||||
|
key
|
||||||
|
.takeIf { it == "api-key" }
|
||||||
|
?.let { TestAppPrincipal(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jwt("jwt") {
|
||||||
|
realm = "Server"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
specOverrides = {
|
||||||
|
this.copy(
|
||||||
|
components = Components(
|
||||||
|
securitySchemes = mutableMapOf(
|
||||||
|
"jwt" to BearerAuth("JWT"),
|
||||||
|
"api-key" to ApiKeyAuth(ApiKeyAuth.ApiKeyLocation.HEADER, "X-API-KEY")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { multipleAuthStrategies() }
|
||||||
|
}
|
||||||
|
it("Can provide different scopes on path operations in the same route") {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
snapshotName = "T0074__auth_on_specific_path_operation.json",
|
||||||
|
applicationSetup = {
|
||||||
|
install(Authentication) {
|
||||||
|
oauth("auth-oauth-google") {
|
||||||
|
urlProvider = { "http://localhost:8080/callback" }
|
||||||
|
providerLookup = {
|
||||||
|
OAuthServerSettings.OAuth2ServerSettings(
|
||||||
|
name = "google",
|
||||||
|
authorizeUrl = "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
accessTokenUrl = "https://accounts.google.com/o/oauth2/token",
|
||||||
|
requestMethod = HttpMethod.Post,
|
||||||
|
clientId = "DUMMY_VAL",
|
||||||
|
clientSecret = "DUMMY_VAL",
|
||||||
|
defaultScopes = listOf("https://www.googleapis.com/auth/userinfo.profile"),
|
||||||
|
extraTokenParameters = listOf("access_type" to "offline")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
client = HttpClient(CIO)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
specOverrides = {
|
||||||
|
this.copy(
|
||||||
|
components = Components(
|
||||||
|
securitySchemes = mutableMapOf(
|
||||||
|
"auth-oauth-google" to OAuth(
|
||||||
|
flows = OAuth.Flows(
|
||||||
|
implicit = OAuth.Flows.Implicit(
|
||||||
|
authorizationUrl = "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
scopes = mapOf(
|
||||||
|
"write:pets" to "modify pets in your account",
|
||||||
|
"read:pets" to "read your pets"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { customScopesOnSiblingPathOperations() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,35 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.arrayConstraints
|
||||||
|
import io.bkbn.kompendium.core.util.doubleConstraints
|
||||||
|
import io.bkbn.kompendium.core.util.intConstraints
|
||||||
|
import io.bkbn.kompendium.core.util.stringConstraints
|
||||||
|
import io.bkbn.kompendium.core.util.stringContentEncodingConstraints
|
||||||
|
import io.bkbn.kompendium.core.util.stringPatternConstraints
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumConstraintsTest : DescribeSpec({
|
||||||
|
describe("Constraints") {
|
||||||
|
it("Can apply constraints to an int field") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0059__int_constraints.json") { intConstraints() }
|
||||||
|
}
|
||||||
|
it("Can apply constraints to a double field") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0060__double_constraints.json") { doubleConstraints() }
|
||||||
|
}
|
||||||
|
it("Can apply a min and max length to a string field") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0061__string_min_max_constraints.json") { stringConstraints() }
|
||||||
|
}
|
||||||
|
it("Can apply a pattern to a string field") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0062__string_pattern_constraints.json") { stringPatternConstraints() }
|
||||||
|
}
|
||||||
|
it("Can apply a content encoding and media type to a string field") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0063__string_content_encoding_constraints.json") {
|
||||||
|
stringContentEncodingConstraints()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it("Can apply constraints to an array field") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0064__array_constraints.json") { arrayConstraints() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.defaultParameter
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumDefaultsTest : DescribeSpec({
|
||||||
|
describe("Defaults") {
|
||||||
|
it("Can generate a default parameter value") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0022__query_with_default_parameter.json") { defaultParameter() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,39 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers.openApiTestAllSerializers
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedComplexGenericType
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedGenericResponse
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedMap
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedNestedCollection
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedSimpleRequest
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedSimpleResponse
|
||||||
|
import io.bkbn.kompendium.core.util.enrichedTopLevelCollection
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumEnrichmentTest : DescribeSpec({
|
||||||
|
describe("Enrichment") {
|
||||||
|
it("Can enrich a simple request") {
|
||||||
|
openApiTestAllSerializers("T0055__enriched_simple_request.json") { enrichedSimpleRequest() }
|
||||||
|
}
|
||||||
|
it("Can enrich a simple response") {
|
||||||
|
openApiTestAllSerializers("T0058__enriched_simple_response.json") { enrichedSimpleResponse() }
|
||||||
|
}
|
||||||
|
it("Can enrich a nested collection") {
|
||||||
|
openApiTestAllSerializers("T0056__enriched_nested_collection.json") { enrichedNestedCollection() }
|
||||||
|
}
|
||||||
|
it("Can enrich a complex generic type") {
|
||||||
|
openApiTestAllSerializers(
|
||||||
|
"T0057__enriched_complex_generic_type.json"
|
||||||
|
) { enrichedComplexGenericType() }
|
||||||
|
}
|
||||||
|
it("Can enrich a generic object") {
|
||||||
|
openApiTestAllSerializers("T0067__enriched_generic_object.json") { enrichedGenericResponse() }
|
||||||
|
}
|
||||||
|
it("Can enrich a top level list type") {
|
||||||
|
openApiTestAllSerializers("T0077__enriched_top_level_list.json") { enrichedTopLevelCollection() }
|
||||||
|
}
|
||||||
|
it("can enrich a map type") {
|
||||||
|
openApiTestAllSerializers("T0078__enriched_top_level_map.json") { enrichedMap() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,45 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.dateTimeString
|
||||||
|
import io.bkbn.kompendium.core.util.samePathSameMethod
|
||||||
|
import io.bkbn.kompendium.json.schema.exception.UnknownSchemaException
|
||||||
|
import io.kotest.assertions.throwables.shouldThrow
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
import io.kotest.matchers.should
|
||||||
|
import io.kotest.matchers.string.startWith
|
||||||
|
import io.ktor.server.application.install
|
||||||
|
import io.ktor.server.auth.Authentication
|
||||||
|
import io.ktor.server.auth.UserIdPrincipal
|
||||||
|
import io.ktor.server.auth.basic
|
||||||
|
|
||||||
|
class KompendiumErrorHandlingTest : DescribeSpec({
|
||||||
|
describe("Error Handling") {
|
||||||
|
it("Throws a clear exception when an unidentified type is encountered") {
|
||||||
|
val exception = shouldThrow<UnknownSchemaException> {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
""
|
||||||
|
) { dateTimeString() }
|
||||||
|
}
|
||||||
|
exception.message should startWith("An unknown type was encountered: class java.time.Instant")
|
||||||
|
}
|
||||||
|
it("Throws an exception when same method for same path has been previously registered") {
|
||||||
|
val exception = shouldThrow<IllegalArgumentException> {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
snapshotName = "",
|
||||||
|
applicationSetup = {
|
||||||
|
install(Authentication) {
|
||||||
|
basic("basic") {
|
||||||
|
realm = "Ktor Server"
|
||||||
|
validate { UserIdPrincipal("Placeholder") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
samePathSameMethod()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exception.message should startWith("A route has already been registered for path: /test/{a} and method: GET")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,27 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.exampleParams
|
||||||
|
import io.bkbn.kompendium.core.util.exampleSummaryAndDescription
|
||||||
|
import io.bkbn.kompendium.core.util.optionalReqExample
|
||||||
|
import io.bkbn.kompendium.core.util.reqRespExamples
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumExamplesTest : DescribeSpec({
|
||||||
|
describe("Examples") {
|
||||||
|
it("Can generate example response and request bodies") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0020__example_req_and_resp.json") { reqRespExamples() }
|
||||||
|
}
|
||||||
|
it("Can describe example parameters") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0021__example_parameters.json") { exampleParams() }
|
||||||
|
}
|
||||||
|
it("Can generate example optional request body") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0069__example_optional_req.json") { optionalReqExample() }
|
||||||
|
}
|
||||||
|
it("Can generate example summary and description") {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
"T0075__example_summary_and_description.json"
|
||||||
|
) { exampleSummaryAndDescription() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,27 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.genericException
|
||||||
|
import io.bkbn.kompendium.core.util.multipleExceptions
|
||||||
|
import io.bkbn.kompendium.core.util.polymorphicException
|
||||||
|
import io.bkbn.kompendium.core.util.singleException
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumExceptionsTest : DescribeSpec({
|
||||||
|
describe("Exceptions") {
|
||||||
|
it("Can add an exception status code to a response") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0016__notarized_get_with_exception_response.json") { singleException() }
|
||||||
|
}
|
||||||
|
it("Can support multiple response codes") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0017__notarized_get_with_multiple_exception_responses.json") {
|
||||||
|
multipleExceptions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it("Can add a polymorphic exception response") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0018__polymorphic_error_status_codes.json") { polymorphicException() }
|
||||||
|
}
|
||||||
|
it("Can add a generic exception response") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0019__generic_exception.json") { genericException() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumFreeFormTest : DescribeSpec({
|
||||||
|
// todo Assess strategies here
|
||||||
|
})
|
@ -0,0 +1,67 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.genericPolymorphicResponse
|
||||||
|
import io.bkbn.kompendium.core.util.genericPolymorphicResponseMultipleImpls
|
||||||
|
import io.bkbn.kompendium.core.util.gnarlyGenericResponse
|
||||||
|
import io.bkbn.kompendium.core.util.nestedGenericCollection
|
||||||
|
import io.bkbn.kompendium.core.util.nestedGenericMultipleParamsCollection
|
||||||
|
import io.bkbn.kompendium.core.util.nestedGenericResponse
|
||||||
|
import io.bkbn.kompendium.core.util.overrideSealedTypeIdentifier
|
||||||
|
import io.bkbn.kompendium.core.util.polymorphicCollectionResponse
|
||||||
|
import io.bkbn.kompendium.core.util.polymorphicMapResponse
|
||||||
|
import io.bkbn.kompendium.core.util.polymorphicResponse
|
||||||
|
import io.bkbn.kompendium.core.util.simpleGenericResponse
|
||||||
|
import io.bkbn.kompendium.core.util.subtypeNotCompleteSetOfParentProperties
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumPolymorphismAndGenericsTest : DescribeSpec({
|
||||||
|
describe("Polymorphism and Generics") {
|
||||||
|
it("can generate a polymorphic response type") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0027__polymorphic_response.json") { polymorphicResponse() }
|
||||||
|
}
|
||||||
|
it("Can generate a collection with polymorphic response type") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0028__polymorphic_list_response.json") { polymorphicCollectionResponse() }
|
||||||
|
}
|
||||||
|
it("Can generate a map with a polymorphic response type") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0029__polymorphic_map_response.json") { polymorphicMapResponse() }
|
||||||
|
}
|
||||||
|
it("Can generate a response type with a generic type") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0030__simple_generic_response.json") { simpleGenericResponse() }
|
||||||
|
}
|
||||||
|
it("Can generate a response type with a nested generic type") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0031__nested_generic_response.json") { nestedGenericResponse() }
|
||||||
|
}
|
||||||
|
it("Can generate a polymorphic response type with generics") {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
"T0032__polymorphic_response_with_generics.json"
|
||||||
|
) { genericPolymorphicResponse() }
|
||||||
|
}
|
||||||
|
it("Can handle an absolutely psycho inheritance test") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0033__crazy_polymorphic_example.json") {
|
||||||
|
genericPolymorphicResponseMultipleImpls()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it("Can support nested generic collections") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0039__nested_generic_collection.json") { nestedGenericCollection() }
|
||||||
|
}
|
||||||
|
it("Can support nested generics with multiple type parameters") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0040__nested_generic_multiple_type_params.json") {
|
||||||
|
nestedGenericMultipleParamsCollection()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it("Can handle a really gnarly generic example") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0043__gnarly_generic_example.json") { gnarlyGenericResponse() }
|
||||||
|
}
|
||||||
|
it("Can override the type name for a sealed interface implementation") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0070__sealed_interface_type_name_override.json") {
|
||||||
|
overrideSealedTypeIdentifier()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it("Can serialize an object where the subtype is not a complete set of parent properties") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0071__subtype_not_complete_set_of_parent_properties.json") {
|
||||||
|
subtypeNotCompleteSetOfParentProperties()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,25 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.defaultField
|
||||||
|
import io.bkbn.kompendium.core.util.nonRequiredParam
|
||||||
|
import io.bkbn.kompendium.core.util.nullableField
|
||||||
|
import io.bkbn.kompendium.core.util.requiredParams
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumRequiredFieldsTest : DescribeSpec({
|
||||||
|
describe("Required Fields") {
|
||||||
|
it("Marks a parameter as required if there is no default and it is not marked nullable") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0023__required_param.json") { requiredParams() }
|
||||||
|
}
|
||||||
|
it("Can mark a parameter as not required") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0024__non_required_param.json") { nonRequiredParam() }
|
||||||
|
}
|
||||||
|
it("Does not mark a field as required if a default value is provided") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0025__default_field.json") { defaultField() }
|
||||||
|
}
|
||||||
|
it("Does not mark a nullable field as required") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0026__nullable_field.json") { nullableField() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,29 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.nestedUnderRoot
|
||||||
|
import io.bkbn.kompendium.core.util.paramWrapper
|
||||||
|
import io.bkbn.kompendium.core.util.rootRoute
|
||||||
|
import io.bkbn.kompendium.core.util.simplePathParsing
|
||||||
|
import io.bkbn.kompendium.core.util.trailingSlash
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
|
||||||
|
class KompendiumRouteParsingTest : DescribeSpec({
|
||||||
|
describe("Route Parsing") {
|
||||||
|
it("Can parse a simple path and store it under the expected route") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0012__path_parser.json") { simplePathParsing() }
|
||||||
|
}
|
||||||
|
it("Can notarize the root route") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0013__root_route.json") { rootRoute() }
|
||||||
|
}
|
||||||
|
it("Can notarize a route under the root module without appending trailing slash") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0014__nested_under_root.json") { nestedUnderRoot() }
|
||||||
|
}
|
||||||
|
it("Can notarize a route with a trailing slash") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0015__trailing_slash.json") { trailingSlash() }
|
||||||
|
}
|
||||||
|
it("Can notarize a route with a parameter") {
|
||||||
|
TestHelpers.openApiTestAllSerializers("T0068__param_wrapper.json") { paramWrapper() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -1,80 +1,53 @@
|
|||||||
package io.bkbn.kompendium.core
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
import dev.forst.ktor.apikey.apiKey
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestHelpers.openApiTestAllSerializers
|
import io.bkbn.kompendium.core.fixtures.TestHelpers.openApiTestAllSerializers
|
||||||
import io.bkbn.kompendium.core.util.TestModules.complexRequest
|
import io.bkbn.kompendium.core.util.complexRequest
|
||||||
import io.bkbn.kompendium.core.util.TestModules.customAuthConfig
|
import io.bkbn.kompendium.core.util.customFieldNameResponse
|
||||||
import io.bkbn.kompendium.core.util.TestModules.customFieldNameResponse
|
import io.bkbn.kompendium.core.util.defaultField
|
||||||
import io.bkbn.kompendium.core.util.TestModules.dateTimeString
|
import io.bkbn.kompendium.core.util.fieldOutsideConstructor
|
||||||
import io.bkbn.kompendium.core.util.TestModules.defaultAuthConfig
|
import io.bkbn.kompendium.core.util.headerParameter
|
||||||
import io.bkbn.kompendium.core.util.TestModules.defaultField
|
import io.bkbn.kompendium.core.util.ignoredFieldsResponse
|
||||||
import io.bkbn.kompendium.core.util.TestModules.defaultParameter
|
import io.bkbn.kompendium.core.util.nestedTypeName
|
||||||
import io.bkbn.kompendium.core.util.TestModules.exampleParams
|
import io.bkbn.kompendium.core.util.nonRequiredParam
|
||||||
import io.bkbn.kompendium.core.util.TestModules.genericException
|
import io.bkbn.kompendium.core.util.nonRequiredParams
|
||||||
import io.bkbn.kompendium.core.util.TestModules.genericPolymorphicResponse
|
import io.bkbn.kompendium.core.util.notarizedDelete
|
||||||
import io.bkbn.kompendium.core.util.TestModules.genericPolymorphicResponseMultipleImpls
|
import io.bkbn.kompendium.core.util.notarizedGet
|
||||||
import io.bkbn.kompendium.core.util.TestModules.gnarlyGenericResponse
|
import io.bkbn.kompendium.core.util.notarizedHead
|
||||||
import io.bkbn.kompendium.core.util.TestModules.headerParameter
|
import io.bkbn.kompendium.core.util.notarizedOptions
|
||||||
import io.bkbn.kompendium.core.util.TestModules.ignoredFieldsResponse
|
import io.bkbn.kompendium.core.util.notarizedPatch
|
||||||
import io.bkbn.kompendium.core.util.TestModules.multipleAuthStrategies
|
import io.bkbn.kompendium.core.util.notarizedPost
|
||||||
import io.bkbn.kompendium.core.util.TestModules.multipleExceptions
|
import io.bkbn.kompendium.core.util.notarizedPut
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nestedGenericCollection
|
import io.bkbn.kompendium.core.util.nullableEnumField
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nestedGenericMultipleParamsCollection
|
import io.bkbn.kompendium.core.util.nullableField
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nestedGenericResponse
|
import io.bkbn.kompendium.core.util.nullableNestedObject
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nestedTypeName
|
import io.bkbn.kompendium.core.util.nullableReference
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nestedUnderRoot
|
import io.bkbn.kompendium.core.util.overrideMediaTypes
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nonRequiredParam
|
import io.bkbn.kompendium.core.util.postNoReqBody
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nonRequiredParams
|
import io.bkbn.kompendium.core.util.primitives
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedDelete
|
import io.bkbn.kompendium.core.util.requiredParams
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedGet
|
import io.bkbn.kompendium.core.util.responseHeaders
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedHead
|
import io.bkbn.kompendium.core.util.returnsEnumList
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedOptions
|
import io.bkbn.kompendium.core.util.returnsList
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedPatch
|
import io.bkbn.kompendium.core.util.samePathDifferentMethodsAndAuth
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedPost
|
import io.bkbn.kompendium.core.util.simpleRecursive
|
||||||
import io.bkbn.kompendium.core.util.TestModules.notarizedPut
|
import io.bkbn.kompendium.core.util.topLevelNullable
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nullableEnumField
|
import io.bkbn.kompendium.core.util.unbackedFieldsResponse
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nullableField
|
import io.bkbn.kompendium.core.util.withOperationId
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nullableNestedObject
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.nullableReference
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicCollectionResponse
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicException
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicMapResponse
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.polymorphicResponse
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.primitives
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.reqRespExamples
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.requiredParams
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.returnsList
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.rootRoute
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.simpleGenericResponse
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.simplePathParsing
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.simpleRecursive
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.singleException
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.trailingSlash
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.unbackedFieldsResponse
|
|
||||||
import io.bkbn.kompendium.core.util.TestModules.withOperationId
|
|
||||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
|
||||||
import io.bkbn.kompendium.json.schema.exception.UnknownSchemaException
|
|
||||||
import io.bkbn.kompendium.oas.component.Components
|
import io.bkbn.kompendium.oas.component.Components
|
||||||
import io.bkbn.kompendium.oas.security.ApiKeyAuth
|
|
||||||
import io.bkbn.kompendium.oas.security.BasicAuth
|
import io.bkbn.kompendium.oas.security.BasicAuth
|
||||||
import io.bkbn.kompendium.oas.security.BearerAuth
|
import io.bkbn.kompendium.oas.serialization.KompendiumSerializersModule
|
||||||
import io.bkbn.kompendium.oas.security.OAuth
|
|
||||||
import io.kotest.assertions.throwables.shouldThrow
|
|
||||||
import io.kotest.core.spec.style.DescribeSpec
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
import io.kotest.matchers.should
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.kotest.matchers.string.startWith
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.engine.cio.CIO
|
|
||||||
import io.ktor.http.HttpMethod
|
|
||||||
import io.ktor.server.application.install
|
import io.ktor.server.application.install
|
||||||
import io.ktor.server.auth.Authentication
|
import io.ktor.server.auth.Authentication
|
||||||
import io.ktor.server.auth.OAuthServerSettings
|
|
||||||
import io.ktor.server.auth.UserIdPrincipal
|
import io.ktor.server.auth.UserIdPrincipal
|
||||||
import io.ktor.server.auth.basic
|
import io.ktor.server.auth.basic
|
||||||
import io.ktor.server.auth.jwt.jwt
|
import io.ktor.server.response.respondText
|
||||||
import io.ktor.server.auth.oauth
|
import io.ktor.server.routing.get
|
||||||
import kotlin.reflect.typeOf
|
import io.ktor.server.routing.route
|
||||||
import java.time.Instant
|
import kotlinx.serialization.encodeToString
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
class KompendiumTest : DescribeSpec({
|
class KompendiumTest : DescribeSpec({
|
||||||
describe("Notarized Open API Metadata Tests") {
|
describe("Notarized Open API Metadata Tests") {
|
||||||
@ -111,46 +84,14 @@ class KompendiumTest : DescribeSpec({
|
|||||||
it("Can notarize a route with non-required params") {
|
it("Can notarize a route with non-required params") {
|
||||||
openApiTestAllSerializers("T0011__non_required_params.json") { nonRequiredParams() }
|
openApiTestAllSerializers("T0011__non_required_params.json") { nonRequiredParams() }
|
||||||
}
|
}
|
||||||
|
it("Can override media types") {
|
||||||
|
openApiTestAllSerializers("T0052__override_media_types.json") { overrideMediaTypes() }
|
||||||
}
|
}
|
||||||
describe("Route Parsing") {
|
it("Can support a post request with no request body") {
|
||||||
it("Can parse a simple path and store it under the expected route") {
|
openApiTestAllSerializers("T0065__post_no_req_body.json") { postNoReqBody() }
|
||||||
openApiTestAllSerializers("T0012__path_parser.json") { simplePathParsing() }
|
|
||||||
}
|
}
|
||||||
it("Can notarize the root route") {
|
it("Can notarize a route with response headers") {
|
||||||
openApiTestAllSerializers("T0013__root_route.json") { rootRoute() }
|
openApiTestAllSerializers("T0066__notarized_get_with_response_headers.json") { responseHeaders() }
|
||||||
}
|
|
||||||
it("Can notarize a route under the root module without appending trailing slash") {
|
|
||||||
openApiTestAllSerializers("T0014__nested_under_root.json") { nestedUnderRoot() }
|
|
||||||
}
|
|
||||||
it("Can notarize a route with a trailing slash") {
|
|
||||||
openApiTestAllSerializers("T0015__trailing_slash.json") { trailingSlash() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
describe("Exceptions") {
|
|
||||||
it("Can add an exception status code to a response") {
|
|
||||||
openApiTestAllSerializers("T0016__notarized_get_with_exception_response.json") { singleException() }
|
|
||||||
}
|
|
||||||
it("Can support multiple response codes") {
|
|
||||||
openApiTestAllSerializers("T0017__notarized_get_with_multiple_exception_responses.json") { multipleExceptions() }
|
|
||||||
}
|
|
||||||
it("Can add a polymorphic exception response") {
|
|
||||||
openApiTestAllSerializers("T0018__polymorphic_error_status_codes.json") { polymorphicException() }
|
|
||||||
}
|
|
||||||
it("Can add a generic exception response") {
|
|
||||||
openApiTestAllSerializers("T0019__generic_exception.json") { genericException() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
describe("Examples") {
|
|
||||||
it("Can generate example response and request bodies") {
|
|
||||||
openApiTestAllSerializers("T0020__example_req_and_resp.json") { reqRespExamples() }
|
|
||||||
}
|
|
||||||
it("Can describe example parameters") {
|
|
||||||
openApiTestAllSerializers("T0021__example_parameters.json") { exampleParams() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
describe("Defaults") {
|
|
||||||
it("Can generate a default parameter value") {
|
|
||||||
openApiTestAllSerializers("T0022__query_with_default_parameter.json") { defaultParameter() }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
describe("Required Fields") {
|
describe("Required Fields") {
|
||||||
@ -167,40 +108,6 @@ class KompendiumTest : DescribeSpec({
|
|||||||
openApiTestAllSerializers("T0026__nullable_field.json") { nullableField() }
|
openApiTestAllSerializers("T0026__nullable_field.json") { nullableField() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
describe("Polymorphism and Generics") {
|
|
||||||
it("can generate a polymorphic response type") {
|
|
||||||
openApiTestAllSerializers("T0027__polymorphic_response.json") { polymorphicResponse() }
|
|
||||||
}
|
|
||||||
it("Can generate a collection with polymorphic response type") {
|
|
||||||
openApiTestAllSerializers("T0028__polymorphic_list_response.json") { polymorphicCollectionResponse() }
|
|
||||||
}
|
|
||||||
it("Can generate a map with a polymorphic response type") {
|
|
||||||
openApiTestAllSerializers("T0029__polymorphic_map_response.json") { polymorphicMapResponse() }
|
|
||||||
}
|
|
||||||
it("Can generate a response type with a generic type") {
|
|
||||||
openApiTestAllSerializers("T0030__simple_generic_response.json") { simpleGenericResponse() }
|
|
||||||
}
|
|
||||||
it("Can generate a response type with a nested generic type") {
|
|
||||||
openApiTestAllSerializers("T0031__nested_generic_response.json") { nestedGenericResponse() }
|
|
||||||
}
|
|
||||||
it("Can generate a polymorphic response type with generics") {
|
|
||||||
openApiTestAllSerializers("T0032__polymorphic_response_with_generics.json") { genericPolymorphicResponse() }
|
|
||||||
}
|
|
||||||
it("Can handle an absolutely psycho inheritance test") {
|
|
||||||
openApiTestAllSerializers("T0033__crazy_polymorphic_example.json") { genericPolymorphicResponseMultipleImpls() }
|
|
||||||
}
|
|
||||||
it("Can support nested generic collections") {
|
|
||||||
openApiTestAllSerializers("T0039__nested_generic_collection.json") { nestedGenericCollection() }
|
|
||||||
}
|
|
||||||
it("Can support nested generics with multiple type parameters") {
|
|
||||||
openApiTestAllSerializers("T0040__nested_generic_multiple_type_params.json") {
|
|
||||||
nestedGenericMultipleParamsCollection()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it("Can handle a really gnarly generic example") {
|
|
||||||
openApiTestAllSerializers("T0043__gnarly_generic_example.json") { gnarlyGenericResponse() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
describe("Custom Serializable Reader tests") {
|
describe("Custom Serializable Reader tests") {
|
||||||
it("Can support ignoring fields") {
|
it("Can support ignoring fields") {
|
||||||
openApiTestAllSerializers("T0048__ignored_property.json") { ignoredFieldsResponse() }
|
openApiTestAllSerializers("T0048__ignored_property.json") { ignoredFieldsResponse() }
|
||||||
@ -237,37 +144,21 @@ class KompendiumTest : DescribeSpec({
|
|||||||
it("Can have a nullable enum as a member field") {
|
it("Can have a nullable enum as a member field") {
|
||||||
openApiTestAllSerializers("T0037__nullable_enum_field.json") { nullableEnumField() }
|
openApiTestAllSerializers("T0037__nullable_enum_field.json") { nullableEnumField() }
|
||||||
}
|
}
|
||||||
|
it("Can have a list of enums as a field") {
|
||||||
|
openApiTestAllSerializers("T0076__list_of_enums.json") { returnsEnumList() }
|
||||||
|
}
|
||||||
it("Can have a nullable reference without impacting base type") {
|
it("Can have a nullable reference without impacting base type") {
|
||||||
openApiTestAllSerializers("T0041__nullable_reference.json") { nullableReference() }
|
openApiTestAllSerializers("T0041__nullable_reference.json") { nullableReference() }
|
||||||
}
|
}
|
||||||
it("Can handle nested type names") {
|
it("Can handle nested type names") {
|
||||||
openApiTestAllSerializers("T0044__nested_type_name.json") { nestedTypeName() }
|
openApiTestAllSerializers("T0044__nested_type_name.json") { nestedTypeName() }
|
||||||
}
|
}
|
||||||
|
it("Can handle top level nullable types") {
|
||||||
|
openApiTestAllSerializers("T0051__top_level_nullable.json") { topLevelNullable() }
|
||||||
}
|
}
|
||||||
describe("Error Handling") {
|
it("Can handle multiple registrations for different methods with the same path and different auth") {
|
||||||
it("Throws a clear exception when an unidentified type is encountered") {
|
|
||||||
val exception = shouldThrow<UnknownSchemaException> { openApiTestAllSerializers("") { dateTimeString() } }
|
|
||||||
exception.message should startWith("An unknown type was encountered: class java.time.Instant")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
describe("Constraints") {
|
|
||||||
// TODO Assess strategies here
|
|
||||||
}
|
|
||||||
describe("Formats") {
|
|
||||||
it("Can set a format for a simple type schema") {
|
|
||||||
openApiTestAllSerializers(
|
openApiTestAllSerializers(
|
||||||
snapshotName = "T0038__formatted_date_time_string.json",
|
"T0053__same_path_different_methods_and_auth.json",
|
||||||
customTypes = mapOf(typeOf<Instant>() to TypeDefinition(type = "string", format = "date"))
|
|
||||||
) { dateTimeString() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
describe("Free Form") {
|
|
||||||
// todo Assess strategies here
|
|
||||||
}
|
|
||||||
describe("Authentication") {
|
|
||||||
it("Can add a default auth config by default") {
|
|
||||||
openApiTestAllSerializers(
|
|
||||||
snapshotName = "T0045__default_auth_config.json",
|
|
||||||
applicationSetup = {
|
applicationSetup = {
|
||||||
install(Authentication) {
|
install(Authentication) {
|
||||||
basic("basic") {
|
basic("basic") {
|
||||||
@ -285,79 +176,54 @@ class KompendiumTest : DescribeSpec({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) { defaultAuthConfig() }
|
) { samePathDifferentMethodsAndAuth() }
|
||||||
}
|
}
|
||||||
it("Can provide custom auth config with proper scopes") {
|
it("Can generate paths without application root-path") {
|
||||||
openApiTestAllSerializers(
|
openApiTestAllSerializers(
|
||||||
snapshotName = "T0046__custom_auth_config.json",
|
"T0054__app_with_rootpath.json",
|
||||||
applicationSetup = {
|
applicationSetup = {
|
||||||
install(Authentication) {
|
rootPath = "/example"
|
||||||
oauth("auth-oauth-google") {
|
},
|
||||||
urlProvider = { "http://localhost:8080/callback" }
|
specOverrides = {
|
||||||
providerLookup = {
|
copy(
|
||||||
OAuthServerSettings.OAuth2ServerSettings(
|
servers = servers.map { it.copy(url = URI("${it.url}/example")) }.toMutableList()
|
||||||
name = "google",
|
|
||||||
authorizeUrl = "https://accounts.google.com/o/oauth2/auth",
|
|
||||||
accessTokenUrl = "https://accounts.google.com/o/oauth2/token",
|
|
||||||
requestMethod = HttpMethod.Post,
|
|
||||||
clientId = "DUMMY_VAL",
|
|
||||||
clientSecret = "DUMMY_VAL",
|
|
||||||
defaultScopes = listOf("https://www.googleapis.com/auth/userinfo.profile"),
|
|
||||||
extraTokenParameters = listOf("access_type" to "offline")
|
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
serverConfigSetup = {
|
||||||
|
rootPath = "/example"
|
||||||
|
}
|
||||||
|
) { notarizedGet() }
|
||||||
|
}
|
||||||
|
it("Can apply a custom serialization strategy to the openapi document") {
|
||||||
|
val customJsonEncoder = Json {
|
||||||
|
serializersModule = KompendiumSerializersModule.module
|
||||||
|
encodeDefaults = true
|
||||||
|
explicitNulls = false
|
||||||
|
}
|
||||||
|
openApiTestAllSerializers(
|
||||||
|
snapshotName = "T0072__custom_serialization_strategy.json",
|
||||||
|
notarizedApplicationConfigOverrides = {
|
||||||
|
specRoute = { spec, routing ->
|
||||||
|
routing.route("/openapi.json") {
|
||||||
|
get {
|
||||||
|
call.response.headers.append("Content-Type", "application/json")
|
||||||
|
call.respondText { customJsonEncoder.encodeToString(spec) }
|
||||||
}
|
}
|
||||||
client = HttpClient(CIO)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
specOverrides = {
|
contentNegotiation = {
|
||||||
this.copy(
|
json(
|
||||||
components = Components(
|
Json {
|
||||||
securitySchemes = mutableMapOf(
|
encodeDefaults = true
|
||||||
"auth-oauth-google" to OAuth(
|
explicitNulls = true
|
||||||
flows = OAuth.Flows(
|
}
|
||||||
implicit = OAuth.Flows.Implicit(
|
|
||||||
authorizationUrl = "https://accounts.google.com/o/oauth2/auth",
|
|
||||||
scopes = mapOf(
|
|
||||||
"write:pets" to "modify pets in your account",
|
|
||||||
"read:pets" to "read your pets"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) { customAuthConfig() }
|
) { notarizedGet() }
|
||||||
}
|
}
|
||||||
it("Can provide multiple authentication strategies") {
|
it("Can serialize a data class with a field outside of the constructor") {
|
||||||
openApiTestAllSerializers(
|
openApiTestAllSerializers("T0073__data_class_with_field_outside_constructor.json") { fieldOutsideConstructor() }
|
||||||
snapshotName = "T0047__multiple_auth_strategies.json",
|
|
||||||
applicationSetup = {
|
|
||||||
install(Authentication) {
|
|
||||||
apiKey("api-key") {
|
|
||||||
headerName = "X-API-KEY"
|
|
||||||
validate {
|
|
||||||
UserIdPrincipal("Placeholder")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jwt("jwt") {
|
|
||||||
realm = "Server"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
specOverrides = {
|
|
||||||
this.copy(
|
|
||||||
components = Components(
|
|
||||||
securitySchemes = mutableMapOf(
|
|
||||||
"jwt" to BearerAuth("JWT"),
|
|
||||||
"api-key" to ApiKeyAuth(ApiKeyAuth.ApiKeyLocation.HEADER, "X-API-KEY")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
) { multipleAuthStrategies() }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package io.bkbn.kompendium.core
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||||
|
import io.bkbn.kompendium.core.util.dateTimeString
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.kotest.core.spec.style.DescribeSpec
|
||||||
|
import java.time.Instant
|
||||||
|
import kotlin.reflect.typeOf
|
||||||
|
|
||||||
|
class KompendiumTypeFormatTest : DescribeSpec({
|
||||||
|
describe("Formats") {
|
||||||
|
it("Can set a format for a simple type schema") {
|
||||||
|
TestHelpers.openApiTestAllSerializers(
|
||||||
|
snapshotName = "T0038__formatted_date_time_string.json",
|
||||||
|
customTypes = mapOf(typeOf<Instant>() to TypeDefinition(type = "string", format = "date"))
|
||||||
|
) { dateTimeString() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,88 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.auth.authenticate
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.defaultAuthConfig() {
|
||||||
|
authenticate("basic") {
|
||||||
|
route(rootPath) {
|
||||||
|
basicGetGenerator<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.customAuthConfig() {
|
||||||
|
authenticate("auth-oauth-google") {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
security = mapOf(
|
||||||
|
"auth-oauth-google" to listOf("read:pets")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.customScopesOnSiblingPathOperations() {
|
||||||
|
authenticate("auth-oauth-google") {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
security = mapOf(
|
||||||
|
"auth-oauth-google" to listOf("read:pets")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
request {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
requestType<TestResponse>()
|
||||||
|
}
|
||||||
|
security = mapOf(
|
||||||
|
"auth-oauth-google" to listOf("write:pets")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.multipleAuthStrategies() {
|
||||||
|
authenticate("jwt", "api-key") {
|
||||||
|
route(rootPath) {
|
||||||
|
basicGetGenerator<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
174
core/src/test/kotlin/io/bkbn/kompendium/core/util/Constraints.kt
Normal file
174
core/src/test/kotlin/io/bkbn/kompendium/core/util/Constraints.kt
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.DoubleResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Page
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestNested
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||||
|
import io.bkbn.kompendium.enrichment.CollectionEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.NumberEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.ObjectEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.StringEnrichment
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.intConstraints() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary("Get an int")
|
||||||
|
description("Get an int")
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
description("An int")
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("example") {
|
||||||
|
TestCreatedResponse::id {
|
||||||
|
NumberEnrichment("blah-blah-blah") {
|
||||||
|
minimum = 2
|
||||||
|
maximum = 100
|
||||||
|
multipleOf = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.doubleConstraints() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary("Get a double")
|
||||||
|
description("Get a double")
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
description("A double")
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("example") {
|
||||||
|
DoubleResponse::payload {
|
||||||
|
NumberEnrichment("blah-blah-blah") {
|
||||||
|
minimum = 2.0
|
||||||
|
maximum = 100.0
|
||||||
|
multipleOf = 2.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.stringConstraints() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary("Get a string")
|
||||||
|
description("Get a string with constraints")
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
description("A string")
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("example") {
|
||||||
|
TestNested::nesty {
|
||||||
|
StringEnrichment("blah") {
|
||||||
|
maxLength = 10
|
||||||
|
minLength = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.stringPatternConstraints() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary("Get a string")
|
||||||
|
description("This is a description")
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
description("A string")
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("example") {
|
||||||
|
TestNested::nesty {
|
||||||
|
StringEnrichment("blah") {
|
||||||
|
pattern = "[a-z]+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.stringContentEncodingConstraints() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary("Get a string")
|
||||||
|
description("This is a description")
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
description("A string")
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("example") {
|
||||||
|
TestNested::nesty {
|
||||||
|
StringEnrichment("blah") {
|
||||||
|
contentEncoding = "base64"
|
||||||
|
contentMediaType = "image/png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.arrayConstraints() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary("Get an array")
|
||||||
|
description("Get an array of strings")
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
description("An array")
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("example") {
|
||||||
|
Page<String>::content {
|
||||||
|
CollectionEnrichment<String>("blah") {
|
||||||
|
minItems = 2
|
||||||
|
maxItems = 10
|
||||||
|
uniqueItems = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.SerialNameObject
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TransientObject
|
||||||
|
import io.bkbn.kompendium.core.fixtures.UnbackedObject
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
|
||||||
|
fun Route.ignoredFieldsResponse() = basicGetGenerator<TransientObject>()
|
||||||
|
fun Route.unbackedFieldsResponse() = basicGetGenerator<UnbackedObject>()
|
||||||
|
fun Route.customFieldNameResponse() = basicGetGenerator<SerialNameObject>()
|
@ -0,0 +1,16 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
|
||||||
|
fun Route.defaultParameter() = basicGetGenerator<TestResponse>(
|
||||||
|
params = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "id",
|
||||||
|
`in` = Parameter.Location.path,
|
||||||
|
schema = TypeDefinition.STRING.withDefault("IDK")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
260
core/src/test/kotlin/io/bkbn/kompendium/core/util/Enrichment.kt
Normal file
260
core/src/test/kotlin/io/bkbn/kompendium/core/util/Enrichment.kt
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||||
|
import io.bkbn.kompendium.core.fixtures.GenericObject
|
||||||
|
import io.bkbn.kompendium.core.fixtures.MultiNestedGenerics
|
||||||
|
import io.bkbn.kompendium.core.fixtures.NestedComplexItem
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.enrichment.CollectionEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.MapEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.NumberEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.ObjectEnrichment
|
||||||
|
import io.bkbn.kompendium.enrichment.StringEnrichment
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.enrichedSimpleResponse() {
|
||||||
|
route("/enriched") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("simple") {
|
||||||
|
TestResponse::c {
|
||||||
|
StringEnrichment("blah-blah-blah") {
|
||||||
|
description = "A simple description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A good response")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.enrichedSimpleRequest() {
|
||||||
|
route("/example") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = TestModules.defaultParams
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType(
|
||||||
|
enrichment = ObjectEnrichment("simple") {
|
||||||
|
TestSimpleRequest::a {
|
||||||
|
StringEnrichment("blah-blah-blah") {
|
||||||
|
description = "A simple description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TestSimpleRequest::b {
|
||||||
|
NumberEnrichment("blah-blah-blah") {
|
||||||
|
deprecated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A test request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(TestModules.defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.enrichedNestedCollection() {
|
||||||
|
route("/example") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = TestModules.defaultParams
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType(
|
||||||
|
enrichment = ObjectEnrichment("simple") {
|
||||||
|
ComplexRequest::tables {
|
||||||
|
CollectionEnrichment<NestedComplexItem>("blah-blah") {
|
||||||
|
description = "A nested description"
|
||||||
|
itemEnrichment = ObjectEnrichment("nested") {
|
||||||
|
NestedComplexItem::name {
|
||||||
|
StringEnrichment("beleheh") {
|
||||||
|
description = "A nested description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A test request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(TestModules.defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.enrichedTopLevelCollection() {
|
||||||
|
route("/example") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = TestModules.defaultParams
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType(
|
||||||
|
enrichment = CollectionEnrichment<List<TestSimpleRequest>>("blah-blah") {
|
||||||
|
itemEnrichment = ObjectEnrichment("simple") {
|
||||||
|
TestSimpleRequest::a {
|
||||||
|
StringEnrichment("blah-blah-blah") {
|
||||||
|
description = "A simple description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TestSimpleRequest::b {
|
||||||
|
NumberEnrichment("blah-blah-blah") {
|
||||||
|
deprecated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A test request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(TestModules.defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.enrichedComplexGenericType() {
|
||||||
|
route("/example") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = TestModules.defaultParams
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType(
|
||||||
|
enrichment = ObjectEnrichment("simple") {
|
||||||
|
MultiNestedGenerics<String, ComplexRequest>::content {
|
||||||
|
MapEnrichment<ComplexRequest>("blah") {
|
||||||
|
description = "A nested description"
|
||||||
|
valueEnrichment = ObjectEnrichment("nested") {
|
||||||
|
ComplexRequest::tables {
|
||||||
|
CollectionEnrichment<NestedComplexItem>("blah-blah") {
|
||||||
|
description = "A nested description"
|
||||||
|
itemEnrichment = ObjectEnrichment("nested") {
|
||||||
|
NestedComplexItem::name {
|
||||||
|
StringEnrichment("beleheh") {
|
||||||
|
description = "A nested description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A test request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(TestModules.defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.enrichedGenericResponse() {
|
||||||
|
route("/example") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseType(
|
||||||
|
enrichment = ObjectEnrichment("generic") {
|
||||||
|
description = "another description"
|
||||||
|
GenericObject<TestSimpleRequest>::data {
|
||||||
|
ObjectEnrichment("simple") {
|
||||||
|
description = "also a description"
|
||||||
|
TestSimpleRequest::a {
|
||||||
|
StringEnrichment("blah-blah-blah") {
|
||||||
|
description = "A simple description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TestSimpleRequest::b {
|
||||||
|
NumberEnrichment("blah-blah-blah") {
|
||||||
|
deprecated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A good response")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.enrichedMap() {
|
||||||
|
route("/example") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(TestModules.defaultPathSummary)
|
||||||
|
description(TestModules.defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseType<Map<String, TestSimpleRequest>>(
|
||||||
|
enrichment = MapEnrichment("blah") {
|
||||||
|
description = "A nested description"
|
||||||
|
valueEnrichment = ObjectEnrichment("nested") {
|
||||||
|
TestSimpleRequest::a {
|
||||||
|
StringEnrichment("blah-blah-blah") {
|
||||||
|
description = "A simple description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TestSimpleRequest::b {
|
||||||
|
NumberEnrichment("blah-blah-blah") {
|
||||||
|
deprecated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
description("A good response")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||||
|
import io.ktor.server.auth.authenticate
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.samePathSameMethod() {
|
||||||
|
route(defaultPath) {
|
||||||
|
basicGetGenerator<TestResponse>()
|
||||||
|
authenticate("basic") {
|
||||||
|
basicGetGenerator<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
core/src/test/kotlin/io/bkbn/kompendium/core/util/Examples.kt
Normal file
114
core/src/test/kotlin/io/bkbn/kompendium/core/util/Examples.kt
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestNested
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestRequest
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultRequestDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.bkbn.kompendium.oas.payload.MediaType
|
||||||
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.reqRespExamples() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
description(defaultRequestDescription)
|
||||||
|
requestType<TestRequest>()
|
||||||
|
examples(
|
||||||
|
"Testerina" to MediaType.Example(TestRequest(TestNested("asdf"), 1.5, emptyList()))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
examples(
|
||||||
|
"Testerino" to MediaType.Example(TestResponse("Heya"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.exampleParams() = basicGetGenerator<TestResponse>(
|
||||||
|
params = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "id",
|
||||||
|
`in` = Parameter.Location.path,
|
||||||
|
schema = TypeDefinition.STRING,
|
||||||
|
examples = mapOf(
|
||||||
|
"foo" to MediaType.Example("testing")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fun Route.optionalReqExample() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
description(defaultRequestDescription)
|
||||||
|
requestType<TestRequest>()
|
||||||
|
examples(
|
||||||
|
"Testerina" to MediaType.Example(TestRequest(TestNested("asdf"), 1.5, emptyList()))
|
||||||
|
)
|
||||||
|
required(false)
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
examples(
|
||||||
|
"Testerino" to MediaType.Example(TestResponse("Heya"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.exampleSummaryAndDescription() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary("This is a summary")
|
||||||
|
description("This is a description")
|
||||||
|
request {
|
||||||
|
description("This is a request description")
|
||||||
|
requestType<TestRequest>()
|
||||||
|
examples(
|
||||||
|
"Testerina" to MediaType.Example(
|
||||||
|
TestRequest(TestNested("asdf"), 1.5, emptyList()),
|
||||||
|
"summary",
|
||||||
|
"description"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
description("This is a response description")
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
examples(
|
||||||
|
"Testerino" to MediaType.Example(TestResponse("Heya"), "summary", "description")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
104
core/src/test/kotlin/io/bkbn/kompendium/core/util/Exceptions.kt
Normal file
104
core/src/test/kotlin/io/bkbn/kompendium/core/util/Exceptions.kt
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ExceptionResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Flibbity
|
||||||
|
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.singleException() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
canRespond {
|
||||||
|
description("Bad Things Happened")
|
||||||
|
responseCode(HttpStatusCode.BadRequest)
|
||||||
|
responseType<ExceptionResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.multipleExceptions() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
canRespond {
|
||||||
|
description("Bad Things Happened")
|
||||||
|
responseCode(HttpStatusCode.BadRequest)
|
||||||
|
responseType<ExceptionResponse>()
|
||||||
|
}
|
||||||
|
canRespond {
|
||||||
|
description("Access Denied")
|
||||||
|
responseCode(HttpStatusCode.Forbidden)
|
||||||
|
responseType<ExceptionResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.polymorphicException() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
canRespond {
|
||||||
|
description("Bad Things Happened")
|
||||||
|
responseCode(HttpStatusCode.InternalServerError)
|
||||||
|
responseType<FlibbityGibbit>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.genericException() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
canRespond {
|
||||||
|
description("Bad Things Happened")
|
||||||
|
responseCode(HttpStatusCode.BadRequest)
|
||||||
|
responseType<Flibbity<String>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ColumnSchema
|
||||||
|
import io.bkbn.kompendium.core.fixtures.DateTimeString
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ManyThings
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Nested
|
||||||
|
import io.bkbn.kompendium.core.fixtures.NullableEnum
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ProfileUpdateRequest
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultParams
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultRequestDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.auth.authenticate
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.withOperationId() = basicGetGenerator<TestResponse>(operationId = "getThisDude")
|
||||||
|
fun Route.nullableNestedObject() = basicGetGenerator<ProfileUpdateRequest>()
|
||||||
|
fun Route.nullableEnumField() = basicGetGenerator<NullableEnum>()
|
||||||
|
fun Route.nullableReference() = basicGetGenerator<ManyThings>()
|
||||||
|
fun Route.dateTimeString() = basicGetGenerator<DateTimeString>()
|
||||||
|
fun Route.headerParameter() = basicGetGenerator<TestResponse>(
|
||||||
|
params = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "X-User-Email",
|
||||||
|
`in` = Parameter.Location.header,
|
||||||
|
schema = TypeDefinition.STRING,
|
||||||
|
required = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fun Route.nestedTypeName() = basicGetGenerator<Nested.Response>()
|
||||||
|
fun Route.topLevelNullable() = basicGetGenerator<TestResponse?>()
|
||||||
|
fun Route.simpleRecursive() = basicGetGenerator<ColumnSchema>()
|
||||||
|
fun Route.samePathDifferentMethodsAndAuth() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
authenticate("basic") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
put = PutInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
description(defaultRequestDescription)
|
||||||
|
requestType<TestSimpleRequest>()
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,388 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||||
|
import io.bkbn.kompendium.core.fixtures.SomethingSimilar
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestEnum
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestRequest
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||||
|
import io.bkbn.kompendium.core.metadata.DeleteInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.HeadInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.OptionsInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.PatchInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||||
|
import io.bkbn.kompendium.core.metadata.PutInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultParams
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPath
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.bkbn.kompendium.oas.payload.Header
|
||||||
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
import io.ktor.http.HttpHeaders
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.response.respond
|
||||||
|
import io.ktor.server.response.respondText
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.delete
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import io.ktor.server.routing.head
|
||||||
|
import io.ktor.server.routing.options
|
||||||
|
import io.ktor.server.routing.patch
|
||||||
|
import io.ktor.server.routing.post
|
||||||
|
import io.ktor.server.routing.put
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
|
fun Route.notarizedGet() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
get = GetInfo.builder {
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
call.respondText { "hey dude ‼️ congrats on the get request" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.responseHeaders() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
get = GetInfo.builder {
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseHeaders(
|
||||||
|
mapOf(
|
||||||
|
HttpHeaders.ETag to Header(
|
||||||
|
TypeDefinition.STRING,
|
||||||
|
"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag"
|
||||||
|
),
|
||||||
|
HttpHeaders.LastModified to Header(
|
||||||
|
TypeDefinition.STRING,
|
||||||
|
"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
call.respondText { "hey dude ‼️ congrats on the get request" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.notarizedPost() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType<TestSimpleRequest>()
|
||||||
|
description("A Test request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
call.respondText { "hey dude ‼️ congrats on the post request" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.notarizedPut() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
put = PutInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType<TestSimpleRequest>()
|
||||||
|
description("A Test request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
put {
|
||||||
|
call.respondText { "hey dude ‼️ congrats on the post request" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.notarizedDelete() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
delete = DeleteInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.NoContent)
|
||||||
|
responseType<Unit>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete {
|
||||||
|
call.respond(HttpStatusCode.NoContent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.notarizedPatch() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
patch = PatchInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
description("A Test request")
|
||||||
|
requestType<TestSimpleRequest>()
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
patch {
|
||||||
|
call.respond(HttpStatusCode.Created) { TestCreatedResponse(123, "Nice!") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.notarizedHead() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
head = HeadInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
|
||||||
|
response {
|
||||||
|
description("great!")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<Unit>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
head {
|
||||||
|
call.respond(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.notarizedOptions() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
options = OptionsInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
description("nice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options {
|
||||||
|
call.respond(HttpStatusCode.NoContent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.complexRequest() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
put = PutInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType<ComplexRequest>()
|
||||||
|
description("A Complex request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<TestCreatedResponse>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
patch {
|
||||||
|
call.respond(HttpStatusCode.Created, TestCreatedResponse(123, "nice!"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.primitives() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
put = PutInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType<Int>()
|
||||||
|
description("A Test Request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
responseType<Boolean>()
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.returnsList() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description("A Successful List-y Endeavor")
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<List<TestResponse>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.returnsEnumList() {
|
||||||
|
route(defaultPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = defaultParams
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description("A Successful List-y Endeavor")
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<List<TestEnum>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.nonRequiredParams() {
|
||||||
|
route("/optional") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "notRequired",
|
||||||
|
`in` = Parameter.Location.query,
|
||||||
|
schema = TypeDefinition.STRING,
|
||||||
|
required = false,
|
||||||
|
),
|
||||||
|
Parameter(
|
||||||
|
name = "required",
|
||||||
|
`in` = Parameter.Location.query,
|
||||||
|
schema = TypeDefinition.STRING
|
||||||
|
)
|
||||||
|
)
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseType<Unit>()
|
||||||
|
description("Empty")
|
||||||
|
responseCode(HttpStatusCode.NoContent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.overrideMediaTypes() {
|
||||||
|
route("/media_types") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
put = PutInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
mediaTypes("multipart/form-data", "application/json")
|
||||||
|
requestType<TestRequest>()
|
||||||
|
description("A cool request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
mediaTypes("application/xml")
|
||||||
|
responseType<TestResponse>()
|
||||||
|
description("A good response")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.postNoReqBody() {
|
||||||
|
route("/no_req_body") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
responseType<TestResponse>()
|
||||||
|
description("Cool response")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.fieldOutsideConstructor() {
|
||||||
|
route("/field_outside_constructor") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
post = PostInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
request {
|
||||||
|
requestType<SomethingSimilar>()
|
||||||
|
description("A cool request")
|
||||||
|
}
|
||||||
|
response {
|
||||||
|
responseType<TestResponse>()
|
||||||
|
description("Cool response")
|
||||||
|
responseCode(HttpStatusCode.Created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Barzo
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ChillaxificationMaximization
|
||||||
|
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Flibbity
|
||||||
|
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Foosy
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Gibbity
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Gizmo
|
||||||
|
import io.bkbn.kompendium.core.fixtures.MultiNestedGenerics
|
||||||
|
import io.bkbn.kompendium.core.fixtures.Page
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
|
||||||
|
fun Route.polymorphicResponse() = basicGetGenerator<FlibbityGibbit>()
|
||||||
|
fun Route.polymorphicCollectionResponse() = basicGetGenerator<List<FlibbityGibbit>>()
|
||||||
|
fun Route.polymorphicMapResponse() = basicGetGenerator<Map<String, FlibbityGibbit>>()
|
||||||
|
fun Route.simpleGenericResponse() = basicGetGenerator<Gibbity<String>>()
|
||||||
|
fun Route.gnarlyGenericResponse() = basicGetGenerator<Foosy<Barzo<Int>, String>>()
|
||||||
|
fun Route.nestedGenericResponse() = basicGetGenerator<Gibbity<Map<String, String>>>()
|
||||||
|
fun Route.genericPolymorphicResponse() = basicGetGenerator<Flibbity<Double>>()
|
||||||
|
fun Route.genericPolymorphicResponseMultipleImpls() = basicGetGenerator<Flibbity<FlibbityGibbit>>()
|
||||||
|
fun Route.nestedGenericCollection() = basicGetGenerator<Page<Int>>()
|
||||||
|
fun Route.nestedGenericMultipleParamsCollection() = basicGetGenerator<MultiNestedGenerics<String, ComplexRequest>>()
|
||||||
|
fun Route.overrideSealedTypeIdentifier() = basicGetGenerator<ChillaxificationMaximization>()
|
||||||
|
fun Route.subtypeNotCompleteSetOfParentProperties() = basicGetGenerator<Gizmo>()
|
@ -0,0 +1,32 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.DefaultField
|
||||||
|
import io.bkbn.kompendium.core.fixtures.NullableField
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
|
||||||
|
fun Route.requiredParams() = basicGetGenerator<TestResponse>(
|
||||||
|
params = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "id",
|
||||||
|
`in` = Parameter.Location.path,
|
||||||
|
schema = TypeDefinition.STRING
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fun Route.nonRequiredParam() = basicGetGenerator<TestResponse>(
|
||||||
|
params = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "id",
|
||||||
|
`in` = Parameter.Location.query,
|
||||||
|
schema = TypeDefinition.STRING,
|
||||||
|
required = false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fun Route.defaultField() = basicGetGenerator<DefaultField>()
|
||||||
|
fun Route.nullableField() = basicGetGenerator<NullableField>()
|
@ -0,0 +1,131 @@
|
|||||||
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
|
import io.bkbn.kompendium.core.fixtures.TestResponse
|
||||||
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultParams
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||||
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
import io.ktor.server.routing.param
|
||||||
|
|
||||||
|
fun Route.simplePathParsing() {
|
||||||
|
route("/this") {
|
||||||
|
route("/is") {
|
||||||
|
route("/a") {
|
||||||
|
route("/complex") {
|
||||||
|
route("path") {
|
||||||
|
route("with/an/{id}") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
parameters = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "id",
|
||||||
|
`in` = Parameter.Location.path,
|
||||||
|
schema = TypeDefinition.STRING
|
||||||
|
)
|
||||||
|
)
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.rootRoute() {
|
||||||
|
route(rootPath) {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = listOf(defaultParams.last())
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.nestedUnderRoot() {
|
||||||
|
route("/") {
|
||||||
|
route("/testerino") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.trailingSlash() {
|
||||||
|
route("/test") {
|
||||||
|
route("/") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Route.paramWrapper() {
|
||||||
|
route("/test") {
|
||||||
|
param("a") {
|
||||||
|
param("b") {
|
||||||
|
param("c") {
|
||||||
|
install(NotarizedRoute()) {
|
||||||
|
parameters = listOf(
|
||||||
|
Parameter(
|
||||||
|
name = "test",
|
||||||
|
`in` = Parameter.Location.query,
|
||||||
|
schema = TypeDefinition.STRING
|
||||||
|
)
|
||||||
|
)
|
||||||
|
get = GetInfo.builder {
|
||||||
|
summary(defaultPathSummary)
|
||||||
|
description(defaultPathDescription)
|
||||||
|
response {
|
||||||
|
description(defaultResponseDescription)
|
||||||
|
responseCode(HttpStatusCode.OK)
|
||||||
|
responseType<TestResponse>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,66 +1,28 @@
|
|||||||
package io.bkbn.kompendium.core.util
|
package io.bkbn.kompendium.core.util
|
||||||
|
|
||||||
import io.bkbn.kompendium.core.fixtures.Barzo
|
|
||||||
import io.bkbn.kompendium.core.fixtures.ColumnSchema
|
|
||||||
import io.bkbn.kompendium.core.fixtures.ComplexRequest
|
|
||||||
import io.bkbn.kompendium.core.fixtures.DateTimeString
|
|
||||||
import io.bkbn.kompendium.core.fixtures.DefaultField
|
|
||||||
import io.bkbn.kompendium.core.fixtures.ExceptionResponse
|
|
||||||
import io.bkbn.kompendium.core.fixtures.Flibbity
|
|
||||||
import io.bkbn.kompendium.core.fixtures.FlibbityGibbit
|
|
||||||
import io.bkbn.kompendium.core.fixtures.Foosy
|
|
||||||
import io.bkbn.kompendium.core.fixtures.Gibbity
|
|
||||||
import io.bkbn.kompendium.core.fixtures.ManyThings
|
|
||||||
import io.bkbn.kompendium.core.fixtures.MultiNestedGenerics
|
|
||||||
import io.bkbn.kompendium.core.fixtures.Nested
|
|
||||||
import io.bkbn.kompendium.core.fixtures.NullableEnum
|
|
||||||
import io.bkbn.kompendium.core.fixtures.NullableField
|
|
||||||
import io.bkbn.kompendium.core.fixtures.Page
|
|
||||||
import io.bkbn.kompendium.core.fixtures.ProfileUpdateRequest
|
|
||||||
import io.bkbn.kompendium.core.fixtures.SerialNameObject
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestCreatedResponse
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestNested
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestRequest
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestResponse
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TransientObject
|
|
||||||
import io.bkbn.kompendium.core.fixtures.UnbakcedObject
|
|
||||||
import io.bkbn.kompendium.core.metadata.DeleteInfo
|
|
||||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||||
import io.bkbn.kompendium.core.metadata.HeadInfo
|
|
||||||
import io.bkbn.kompendium.core.metadata.OptionsInfo
|
|
||||||
import io.bkbn.kompendium.core.metadata.PatchInfo
|
|
||||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
|
||||||
import io.bkbn.kompendium.core.metadata.PutInfo
|
|
||||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||||
|
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||||
import io.bkbn.kompendium.oas.payload.Parameter
|
import io.bkbn.kompendium.oas.payload.Parameter
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.server.application.call
|
|
||||||
import io.ktor.server.application.install
|
|
||||||
import io.ktor.server.auth.authenticate
|
|
||||||
import io.ktor.server.response.respond
|
|
||||||
import io.ktor.server.response.respondText
|
|
||||||
import io.ktor.server.routing.Route
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.server.routing.Routing
|
import io.ktor.server.routing.Routing
|
||||||
import io.ktor.server.routing.delete
|
|
||||||
import io.ktor.server.routing.get
|
|
||||||
import io.ktor.server.routing.head
|
|
||||||
import io.ktor.server.routing.options
|
|
||||||
import io.ktor.server.routing.patch
|
|
||||||
import io.ktor.server.routing.post
|
|
||||||
import io.ktor.server.routing.put
|
|
||||||
import io.ktor.server.routing.route
|
import io.ktor.server.routing.route
|
||||||
|
|
||||||
object TestModules {
|
object TestModules {
|
||||||
private const val defaultPath = "/test/{a}"
|
|
||||||
private const val rootPath = "/"
|
|
||||||
private const val defaultResponseDescription = "A Successful Endeavor"
|
|
||||||
private const val defaultRequestDescription = "You gotta send it"
|
|
||||||
private const val defaultPathSummary = "Great Summary!"
|
|
||||||
private const val defaultPathDescription = "testing more"
|
|
||||||
|
|
||||||
private val defaultParams = listOf(
|
const val defaultPath = "/test/{a}"
|
||||||
|
const val rootPath = "/"
|
||||||
|
const val defaultResponseDescription = "A Successful Endeavor"
|
||||||
|
const val defaultRequestDescription = "You gotta send it"
|
||||||
|
const val defaultPathSummary = "Great Summary!"
|
||||||
|
const val defaultPathDescription = "testing more"
|
||||||
|
|
||||||
|
val defaultParams = listOf(
|
||||||
Parameter(
|
Parameter(
|
||||||
name = "a",
|
name = "a",
|
||||||
`in` = Parameter.Location.path,
|
`in` = Parameter.Location.path,
|
||||||
@ -72,587 +34,9 @@ object TestModules {
|
|||||||
schema = TypeDefinition.INT
|
schema = TypeDefinition.INT
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun Routing.notarizedGet() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
get = GetInfo.builder {
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get {
|
|
||||||
call.respondText { "hey dude ‼️ congrats on the get request" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Routing.notarizedPost() {
|
internal inline fun <reified T> Routing.basicGetGenerator(
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
post = PostInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
request {
|
|
||||||
requestType<TestSimpleRequest>()
|
|
||||||
description("A Test request")
|
|
||||||
}
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.Created)
|
|
||||||
responseType<TestCreatedResponse>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
call.respondText { "hey dude ‼️ congrats on the post request" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.notarizedPut() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
put = PutInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
request {
|
|
||||||
requestType<TestSimpleRequest>()
|
|
||||||
description("A Test request")
|
|
||||||
}
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.Created)
|
|
||||||
responseType<TestCreatedResponse>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
put {
|
|
||||||
call.respondText { "hey dude ‼️ congrats on the post request" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.notarizedDelete() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
delete = DeleteInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.NoContent)
|
|
||||||
responseType<Unit>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete {
|
|
||||||
call.respond(HttpStatusCode.NoContent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.notarizedPatch() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
patch = PatchInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
request {
|
|
||||||
description("A Test request")
|
|
||||||
requestType<TestSimpleRequest>()
|
|
||||||
}
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.Created)
|
|
||||||
responseType<TestCreatedResponse>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
patch {
|
|
||||||
call.respond(HttpStatusCode.Created) { TestCreatedResponse(123, "Nice!") }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.notarizedHead() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
head = HeadInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
|
|
||||||
response {
|
|
||||||
description("great!")
|
|
||||||
responseCode(HttpStatusCode.Created)
|
|
||||||
responseType<Unit>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
head {
|
|
||||||
call.respond(HttpStatusCode.OK)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.notarizedOptions() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
options = OptionsInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
description("nice")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options {
|
|
||||||
call.respond(HttpStatusCode.NoContent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.complexRequest() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
put = PutInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
request {
|
|
||||||
requestType<ComplexRequest>()
|
|
||||||
description("A Complex request")
|
|
||||||
}
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.Created)
|
|
||||||
responseType<TestCreatedResponse>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
patch {
|
|
||||||
call.respond(HttpStatusCode.Created, TestCreatedResponse(123, "nice!"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.primitives() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
put = PutInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
request {
|
|
||||||
requestType<Int>()
|
|
||||||
description("A Test Request")
|
|
||||||
}
|
|
||||||
response {
|
|
||||||
responseCode(HttpStatusCode.Created)
|
|
||||||
responseType<Boolean>()
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.returnsList() {
|
|
||||||
route(defaultPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = defaultParams
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description("A Successful List-y Endeavor")
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<List<TestResponse>>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.nonRequiredParams() {
|
|
||||||
route("/optional") {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "notRequired",
|
|
||||||
`in` = Parameter.Location.query,
|
|
||||||
schema = TypeDefinition.STRING,
|
|
||||||
required = false,
|
|
||||||
),
|
|
||||||
Parameter(
|
|
||||||
name = "required",
|
|
||||||
`in` = Parameter.Location.query,
|
|
||||||
schema = TypeDefinition.STRING
|
|
||||||
)
|
|
||||||
)
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
responseType<Unit>()
|
|
||||||
description("Empty")
|
|
||||||
responseCode(HttpStatusCode.NoContent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.simplePathParsing() {
|
|
||||||
route("/this") {
|
|
||||||
route("/is") {
|
|
||||||
route("/a") {
|
|
||||||
route("/complex") {
|
|
||||||
route("path") {
|
|
||||||
route("with/an/{id}") {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
parameters = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "id",
|
|
||||||
`in` = Parameter.Location.path,
|
|
||||||
schema = TypeDefinition.STRING
|
|
||||||
)
|
|
||||||
)
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.rootRoute() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
parameters = listOf(defaultParams.last())
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.nestedUnderRoot() {
|
|
||||||
route("/") {
|
|
||||||
route("/testerino") {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.trailingSlash() {
|
|
||||||
route("/test") {
|
|
||||||
route("/") {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.singleException() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
canRespond {
|
|
||||||
description("Bad Things Happened")
|
|
||||||
responseCode(HttpStatusCode.BadRequest)
|
|
||||||
responseType<ExceptionResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.multipleExceptions() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
canRespond {
|
|
||||||
description("Bad Things Happened")
|
|
||||||
responseCode(HttpStatusCode.BadRequest)
|
|
||||||
responseType<ExceptionResponse>()
|
|
||||||
}
|
|
||||||
canRespond {
|
|
||||||
description("Access Denied")
|
|
||||||
responseCode(HttpStatusCode.Forbidden)
|
|
||||||
responseType<ExceptionResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.polymorphicException() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
canRespond {
|
|
||||||
description("Bad Things Happened")
|
|
||||||
responseCode(HttpStatusCode.InternalServerError)
|
|
||||||
responseType<FlibbityGibbit>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.genericException() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
canRespond {
|
|
||||||
description("Bad Things Happened")
|
|
||||||
responseCode(HttpStatusCode.BadRequest)
|
|
||||||
responseType<Flibbity<String>>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.reqRespExamples() {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
post = PostInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
request {
|
|
||||||
description(defaultRequestDescription)
|
|
||||||
requestType<TestRequest>()
|
|
||||||
examples(
|
|
||||||
"Testerina" to TestRequest(TestNested("asdf"), 1.5, emptyList())
|
|
||||||
)
|
|
||||||
}
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
examples(
|
|
||||||
"Testerino" to TestResponse("Heya")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.exampleParams() = basicGetGenerator<TestResponse>(
|
|
||||||
params = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "id",
|
|
||||||
`in` = Parameter.Location.path,
|
|
||||||
schema = TypeDefinition.STRING,
|
|
||||||
examples = mapOf(
|
|
||||||
"foo" to Parameter.Example("testing")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun Routing.defaultParameter() = basicGetGenerator<TestResponse>(
|
|
||||||
params = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "id",
|
|
||||||
`in` = Parameter.Location.path,
|
|
||||||
schema = TypeDefinition.STRING.withDefault("IDK")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun Routing.requiredParams() = basicGetGenerator<TestResponse>(
|
|
||||||
params = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "id",
|
|
||||||
`in` = Parameter.Location.path,
|
|
||||||
schema = TypeDefinition.STRING
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun Routing.nonRequiredParam() = basicGetGenerator<TestResponse>(
|
|
||||||
params = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "id",
|
|
||||||
`in` = Parameter.Location.query,
|
|
||||||
schema = TypeDefinition.STRING,
|
|
||||||
required = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun Routing.defaultField() = basicGetGenerator<DefaultField>()
|
|
||||||
|
|
||||||
fun Routing.nullableField() = basicGetGenerator<NullableField>()
|
|
||||||
|
|
||||||
fun Routing.polymorphicResponse() = basicGetGenerator<FlibbityGibbit>()
|
|
||||||
|
|
||||||
fun Routing.ignoredFieldsResponse() = basicGetGenerator<TransientObject>()
|
|
||||||
|
|
||||||
fun Routing.unbackedFieldsResponse() = basicGetGenerator<UnbakcedObject>()
|
|
||||||
|
|
||||||
fun Routing.customFieldNameResponse() = basicGetGenerator<SerialNameObject>()
|
|
||||||
|
|
||||||
fun Routing.polymorphicCollectionResponse() = basicGetGenerator<List<FlibbityGibbit>>()
|
|
||||||
|
|
||||||
fun Routing.polymorphicMapResponse() = basicGetGenerator<Map<String, FlibbityGibbit>>()
|
|
||||||
|
|
||||||
fun Routing.simpleGenericResponse() = basicGetGenerator<Gibbity<String>>()
|
|
||||||
|
|
||||||
fun Routing.gnarlyGenericResponse() = basicGetGenerator<Foosy<Barzo<Int>, String>>()
|
|
||||||
|
|
||||||
fun Routing.nestedGenericResponse() = basicGetGenerator<Gibbity<Map<String, String>>>()
|
|
||||||
|
|
||||||
fun Routing.genericPolymorphicResponse() = basicGetGenerator<Flibbity<Double>>()
|
|
||||||
|
|
||||||
fun Routing.genericPolymorphicResponseMultipleImpls() = basicGetGenerator<Flibbity<FlibbityGibbit>>()
|
|
||||||
|
|
||||||
fun Routing.nestedGenericCollection() = basicGetGenerator<Page<Int>>()
|
|
||||||
|
|
||||||
fun Routing.nestedGenericMultipleParamsCollection() = basicGetGenerator<MultiNestedGenerics<String, ComplexRequest>>()
|
|
||||||
|
|
||||||
fun Routing.withOperationId() = basicGetGenerator<TestResponse>(operationId = "getThisDude")
|
|
||||||
|
|
||||||
fun Routing.nullableNestedObject() = basicGetGenerator<ProfileUpdateRequest>()
|
|
||||||
|
|
||||||
fun Routing.nullableEnumField() = basicGetGenerator<NullableEnum>()
|
|
||||||
|
|
||||||
fun Routing.nullableReference() = basicGetGenerator<ManyThings>()
|
|
||||||
|
|
||||||
fun Routing.dateTimeString() = basicGetGenerator<DateTimeString>()
|
|
||||||
|
|
||||||
fun Routing.headerParameter() = basicGetGenerator<TestResponse>(
|
|
||||||
params = listOf(
|
|
||||||
Parameter(
|
|
||||||
name = "X-User-Email",
|
|
||||||
`in` = Parameter.Location.header,
|
|
||||||
schema = TypeDefinition.STRING,
|
|
||||||
required = true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun Routing.nestedTypeName() = basicGetGenerator<Nested.Response>()
|
|
||||||
|
|
||||||
fun Routing.simpleRecursive() = basicGetGenerator<ColumnSchema>()
|
|
||||||
|
|
||||||
fun Routing.defaultAuthConfig() {
|
|
||||||
authenticate("basic") {
|
|
||||||
route(rootPath) {
|
|
||||||
basicGetGenerator<TestResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.customAuthConfig() {
|
|
||||||
authenticate("auth-oauth-google") {
|
|
||||||
route(rootPath) {
|
|
||||||
install(NotarizedRoute()) {
|
|
||||||
get = GetInfo.builder {
|
|
||||||
summary(defaultPathSummary)
|
|
||||||
description(defaultPathDescription)
|
|
||||||
response {
|
|
||||||
description(defaultResponseDescription)
|
|
||||||
responseCode(HttpStatusCode.OK)
|
|
||||||
responseType<TestResponse>()
|
|
||||||
}
|
|
||||||
security = mapOf(
|
|
||||||
"auth-oauth-google" to listOf("read:pets")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Routing.multipleAuthStrategies() {
|
|
||||||
authenticate("jwt", "api-key") {
|
|
||||||
route(rootPath) {
|
|
||||||
basicGetGenerator<TestResponse>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline fun <reified T> Routing.basicGetGenerator(
|
|
||||||
params: List<Parameter> = emptyList(),
|
params: List<Parameter> = emptyList(),
|
||||||
operationId: String? = null
|
operationId: String? = null
|
||||||
) {
|
) {
|
||||||
@ -661,7 +45,7 @@ object TestModules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <reified T> Route.basicGetGenerator(
|
internal inline fun <reified T> Route.basicGetGenerator(
|
||||||
params: List<Parameter> = emptyList(),
|
params: List<Parameter> = emptyList(),
|
||||||
operationId: String? = null
|
operationId: String? = null
|
||||||
) {
|
) {
|
||||||
@ -679,4 +63,3 @@ object TestModules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -124,15 +124,18 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"enumeration": {
|
"enumeration": {
|
||||||
"enum": [
|
"$ref": "#/components/schemas/SimpleEnum"
|
||||||
"ONE",
|
|
||||||
"TWO"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"enumeration"
|
"enumeration"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"SimpleEnum": {
|
||||||
|
"enum": [
|
||||||
|
"ONE",
|
||||||
|
"TWO"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securitySchemes": {}
|
"securitySchemes": {}
|
||||||
|
@ -86,12 +86,18 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.ComplexGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"c",
|
"c",
|
||||||
"z"
|
"z",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SimpleGibbit": {
|
"SimpleGibbit": {
|
||||||
@ -102,10 +108,16 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.SimpleGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"FlibbityGibbit": {
|
"FlibbityGibbit": {
|
||||||
|
@ -82,11 +82,17 @@
|
|||||||
},
|
},
|
||||||
"f": {
|
"f": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.Bibbity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"f"
|
"f",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Gibbity-String": {
|
"Gibbity-String": {
|
||||||
@ -94,10 +100,16 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"a": {
|
"a": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.Gibbity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Flibbity-String": {
|
"Flibbity-String": {
|
||||||
|
@ -65,12 +65,18 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.ComplexGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"c",
|
"c",
|
||||||
"z"
|
"z",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SimpleGibbit": {
|
"SimpleGibbit": {
|
||||||
@ -81,10 +87,16 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.SimpleGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"FlibbityGibbit": {
|
"FlibbityGibbit": {
|
||||||
|
@ -65,12 +65,18 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.ComplexGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"c",
|
"c",
|
||||||
"z"
|
"z",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SimpleGibbit": {
|
"SimpleGibbit": {
|
||||||
@ -81,10 +87,16 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.SimpleGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"List-FlibbityGibbit": {
|
"List-FlibbityGibbit": {
|
||||||
|
@ -65,12 +65,18 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.ComplexGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"c",
|
"c",
|
||||||
"z"
|
"z",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SimpleGibbit": {
|
"SimpleGibbit": {
|
||||||
@ -81,10 +87,16 @@
|
|||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.SimpleGibbit"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Map-String-FlibbityGibbit": {
|
"Map-String-FlibbityGibbit": {
|
||||||
|
@ -62,11 +62,17 @@
|
|||||||
"f": {
|
"f": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"format": "double"
|
"format": "double"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.Bibbity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"f"
|
"f",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Gibbity-Double": {
|
"Gibbity-Double": {
|
||||||
@ -75,10 +81,16 @@
|
|||||||
"a": {
|
"a": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"format": "double"
|
"format": "double"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.Gibbity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Flibbity-Double": {
|
"Flibbity-Double": {
|
||||||
|
@ -53,40 +53,6 @@
|
|||||||
"webhooks": {},
|
"webhooks": {},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ComplexGibbit": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"b": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"c": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "int32"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"b",
|
|
||||||
"c",
|
|
||||||
"z"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"SimpleGibbit": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"a": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"z": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"a"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Bibbity-FlibbityGibbit": {
|
"Bibbity-FlibbityGibbit": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -102,11 +68,63 @@
|
|||||||
"$ref": "#/components/schemas/SimpleGibbit"
|
"$ref": "#/components/schemas/SimpleGibbit"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.Bibbity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"b",
|
"b",
|
||||||
"f"
|
"f",
|
||||||
|
"type"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ComplexGibbit": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"b": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"c": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.ComplexGibbit"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"b",
|
||||||
|
"c",
|
||||||
|
"z",
|
||||||
|
"type"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"SimpleGibbit": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.SimpleGibbit"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Gibbity-FlibbityGibbit": {
|
"Gibbity-FlibbityGibbit": {
|
||||||
@ -121,10 +139,16 @@
|
|||||||
"$ref": "#/components/schemas/SimpleGibbit"
|
"$ref": "#/components/schemas/SimpleGibbit"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"io.bkbn.kompendium.core.fixtures.Gibbity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"a"
|
"a",
|
||||||
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Flibbity-FlibbityGibbit": {
|
"Flibbity-FlibbityGibbit": {
|
||||||
|
@ -91,11 +91,6 @@
|
|||||||
"required": []
|
"required": []
|
||||||
},
|
},
|
||||||
"ProfileMetadataUpdateRequest": {
|
"ProfileMetadataUpdateRequest": {
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "null"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"isPrivate": {
|
"isPrivate": {
|
||||||
@ -121,8 +116,6 @@
|
|||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"securitySchemes": {}
|
"securitySchemes": {}
|
||||||
},
|
},
|
||||||
|
@ -62,15 +62,19 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"enum": [
|
"$ref": "#/components/schemas/TestEnum"
|
||||||
"YES",
|
|
||||||
"NO"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
|
},
|
||||||
|
"TestEnum":
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"YES",
|
||||||
|
"NO"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securitySchemes": {}
|
"securitySchemes": {}
|
||||||
|
@ -57,10 +57,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"enumeration": {
|
"enumeration": {
|
||||||
"enum": [
|
"$ref": "#/components/schemas/SimpleEnum"
|
||||||
"ONE",
|
|
||||||
"TWO"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@ -120,6 +117,12 @@
|
|||||||
"required": [
|
"required": [
|
||||||
"content"
|
"content"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"SimpleEnum": {
|
||||||
|
"enum": [
|
||||||
|
"ONE",
|
||||||
|
"TWO"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securitySchemes": {}
|
"securitySchemes": {}
|
||||||
|
@ -53,6 +53,13 @@
|
|||||||
"webhooks": {},
|
"webhooks": {},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"ColumnMode": {
|
||||||
|
"enum": [
|
||||||
|
"NULLABLE",
|
||||||
|
"REQUIRED",
|
||||||
|
"REPEATED"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ColumnSchema": {
|
"ColumnSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -60,11 +67,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"mode": {
|
"mode": {
|
||||||
"enum": [
|
"$ref": "#/components/schemas/ColumnMode"
|
||||||
"NULLABLE",
|
|
||||||
"REQUIRED",
|
|
||||||
"REPEATED"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/UnbakcedObject"
|
"$ref": "#/components/schemas/UnbackedObject"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@
|
|||||||
"webhooks": {},
|
"webhooks": {},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"UnbakcedObject": {
|
"UnbackedObject": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"backed": {
|
"backed": {
|
||||||
|
79
core/src/test/resources/T0051__top_level_nullable.json
Normal file
79
core/src/test/resources/T0051__top_level_nullable.json
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
123
core/src/test/resources/T0052__override_media_types.json
Normal file
123
core/src/test/resources/T0052__override_media_types.json
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/media_types": {
|
||||||
|
"put": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A cool request",
|
||||||
|
"content": {
|
||||||
|
"multipart/form-data": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestRequest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A good response",
|
||||||
|
"content": {
|
||||||
|
"application/xml": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"aaa": {
|
||||||
|
"items": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "double"
|
||||||
|
},
|
||||||
|
"fieldName": {
|
||||||
|
"$ref": "#/components/schemas/TestNested"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"aaa",
|
||||||
|
"b",
|
||||||
|
"fieldName"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestNested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"nesty": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"nesty"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,164 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "You gotta send it",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestSimpleRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false,
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"basic": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestCreatedResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c",
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestSimpleRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {
|
||||||
|
"basic": {
|
||||||
|
"type": "http",
|
||||||
|
"scheme": "basic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
92
core/src/test/resources/T0054__app_with_rootpath.json
Normal file
92
core/src/test/resources/T0054__app_with_rootpath.json
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com/example",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com/example",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
126
core/src/test/resources/T0055__enriched_simple_request.json
Normal file
126
core/src/test/resources/T0055__enriched_simple_request.json
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/example": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A test request",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestSimpleRequest-simple"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestCreatedResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c",
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestSimpleRequest-simple": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"deprecated": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
186
core/src/test/resources/T0056__enriched_nested_collection.json
Normal file
186
core/src/test/resources/T0056__enriched_nested_collection.json
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/example": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A test request",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ComplexRequest-simple"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestCreatedResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c",
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ComplexRequest-simple": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"amazingField": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"org": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"tables": {
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/NestedComplexItem-blah-blah"
|
||||||
|
},
|
||||||
|
"description": "A nested description",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"amazingField",
|
||||||
|
"org",
|
||||||
|
"tables"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NestedComplexItem-nested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"alias": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/CrazyItem"
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A nested description"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"alias",
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"CrazyItem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"enumeration": {
|
||||||
|
"$ref": "#/components/schemas/SimpleEnum"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"enumeration"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"SimpleEnum": {
|
||||||
|
"enum": [
|
||||||
|
"ONE",
|
||||||
|
"TWO"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NestedComplexItem-blah-blah": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"alias": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/CrazyItem"
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A nested description"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"alias",
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,224 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/example": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A test request",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/MultiNestedGenerics-String-ComplexRequest-simple"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestCreatedResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c",
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"MultiNestedGenerics-String-ComplexRequest-simple": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"content": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/ComplexRequest-blah"
|
||||||
|
},
|
||||||
|
"description": "A nested description",
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"content"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ComplexRequest-nested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"amazingField": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"org": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"tables": {
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/NestedComplexItem-blah-blah"
|
||||||
|
},
|
||||||
|
"description": "A nested description",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"amazingField",
|
||||||
|
"org",
|
||||||
|
"tables"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NestedComplexItem-nested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"alias": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/CrazyItem"
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A nested description"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"alias",
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"CrazyItem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"enumeration": {
|
||||||
|
"$ref": "#/components/schemas/SimpleEnum"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"enumeration"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"SimpleEnum": {
|
||||||
|
"enum": [
|
||||||
|
"ONE",
|
||||||
|
"TWO"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NestedComplexItem-blah-blah": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"alias": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/CrazyItem"
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A nested description"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"alias",
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ComplexRequest-blah": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"amazingField": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"org": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"tables": {
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/NestedComplexItem-blah-blah"
|
||||||
|
},
|
||||||
|
"description": "A nested description",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"amazingField",
|
||||||
|
"org",
|
||||||
|
"tables"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
73
core/src/test/resources/T0058__enriched_simple_response.json
Normal file
73
core/src/test/resources/T0058__enriched_simple_response.json
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/enriched": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A good response",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse-simple"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse-simple": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
80
core/src/test/resources/T0059__int_constraints.json
Normal file
80
core/src/test/resources/T0059__int_constraints.json
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Get an int",
|
||||||
|
"description": "Get an int",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "An int",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestCreatedResponse-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestCreatedResponse-example": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"multipleOf": 2,
|
||||||
|
"maximum": 100,
|
||||||
|
"minimum": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c",
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
76
core/src/test/resources/T0060__double_constraints.json
Normal file
76
core/src/test/resources/T0060__double_constraints.json
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Get a double",
|
||||||
|
"description": "Get a double",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A double",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/DoubleResponse-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"DoubleResponse-example": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"payload": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "double",
|
||||||
|
"multipleOf": 2.0,
|
||||||
|
"maximum": 100.0,
|
||||||
|
"minimum": 2.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"payload"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Get a string",
|
||||||
|
"description": "Get a string with constraints",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A string",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestNested-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestNested-example": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"nesty": {
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 10,
|
||||||
|
"minLength": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"nesty"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Get a string",
|
||||||
|
"description": "This is a description",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A string",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestNested-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestNested-example": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"nesty": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "[a-z]+"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"nesty"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Get a string",
|
||||||
|
"description": "This is a description",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A string",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestNested-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestNested-example": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"nesty": {
|
||||||
|
"type": "string",
|
||||||
|
"contentEncoding": "base64",
|
||||||
|
"contentMediaType": "image/png"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"nesty"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
103
core/src/test/resources/T0064__array_constraints.json
Normal file
103
core/src/test/resources/T0064__array_constraints.json
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Get an array",
|
||||||
|
"description": "Get an array of strings",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "An array",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/Page-String-example"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"Page-String-example": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"content": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"maxItems": 10,
|
||||||
|
"minItems": 2,
|
||||||
|
"uniqueItems": true,
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"number": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"numberOfElements": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"totalElements": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"totalPages": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"content",
|
||||||
|
"number",
|
||||||
|
"numberOfElements",
|
||||||
|
"size",
|
||||||
|
"totalElements",
|
||||||
|
"totalPages"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
72
core/src/test/resources/T0065__post_no_req_body.json
Normal file
72
core/src/test/resources/T0065__post_no_req_body.json
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/no_req_body": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "Cool response",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"headers": {
|
||||||
|
"ETag": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag",
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"Last-Modified": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified",
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
91
core/src/test/resources/T0067__enriched_generic_object.json
Normal file
91
core/src/test/resources/T0067__enriched_generic_object.json
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/example": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A good response",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/GenericObject-TestSimpleRequest-generic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"GenericObject-TestSimpleRequest-generic": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/components/schemas/TestSimpleRequest-simple",
|
||||||
|
"description": "also a description"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"data"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestSimpleRequest-simple": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"deprecated": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
82
core/src/test/resources/T0068__param_wrapper.json
Normal file
82
core/src/test/resources/T0068__param_wrapper.json
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "test",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
136
core/src/test/resources/T0069__example_optional_req.json
Normal file
136
core/src/test/resources/T0069__example_optional_req.json
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "You gotta send it",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestRequest"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"Testerina": {
|
||||||
|
"value": {
|
||||||
|
"fieldName": {
|
||||||
|
"nesty": "asdf"
|
||||||
|
},
|
||||||
|
"b": 1.5,
|
||||||
|
"aaa": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"Testerino": {
|
||||||
|
"value": {
|
||||||
|
"c": "Heya"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"aaa": {
|
||||||
|
"items": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "double"
|
||||||
|
},
|
||||||
|
"fieldName": {
|
||||||
|
"$ref": "#/components/schemas/TestNested"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"aaa",
|
||||||
|
"b",
|
||||||
|
"fieldName"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestNested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"nesty": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"nesty"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ChillaxificationMaximization"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"Chillax": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"chillax"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"type"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ToDaMax": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"maximize"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"b",
|
||||||
|
"type"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ChillaxificationMaximization": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/Chillax"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/ToDaMax"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/Gizmo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"Gizmo": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"title": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"title"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/field_outside_constructor": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A cool request",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/SomethingSimilar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "Cool response",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"SomethingSimilar": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false,
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"auth-oauth-google": [
|
||||||
|
"read:pets"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false,
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"auth-oauth-google": [
|
||||||
|
"write:pets"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {
|
||||||
|
"auth-oauth-google": {
|
||||||
|
"flows": {
|
||||||
|
"implicit": {
|
||||||
|
"authorizationUrl": "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
"scopes": {
|
||||||
|
"write:pets": "modify pets in your account",
|
||||||
|
"read:pets": "read your pets"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "oauth2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "This is a summary",
|
||||||
|
"description": "This is a description",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "This is a request description",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestRequest"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"Testerina": {
|
||||||
|
"value": {
|
||||||
|
"fieldName": {
|
||||||
|
"nesty": "asdf"
|
||||||
|
},
|
||||||
|
"b": 1.5,
|
||||||
|
"aaa": []
|
||||||
|
},
|
||||||
|
"summary": "summary",
|
||||||
|
"description": "description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "This is a response description",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestResponse"
|
||||||
|
},
|
||||||
|
"examples": {
|
||||||
|
"Testerino": {
|
||||||
|
"value": {
|
||||||
|
"c": "Heya"
|
||||||
|
},
|
||||||
|
"summary": "summary",
|
||||||
|
"description": "description"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"aaa": {
|
||||||
|
"items": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "double"
|
||||||
|
},
|
||||||
|
"fieldName": {
|
||||||
|
"$ref": "#/components/schemas/TestNested"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"aaa",
|
||||||
|
"b",
|
||||||
|
"fieldName"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestNested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"nesty": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"nesty"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
93
core/src/test/resources/T0076__list_of_enums.json
Normal file
93
core/src/test/resources/T0076__list_of_enums.json
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/test/{a}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A Successful List-y Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/List-TestEnum"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestEnum": {
|
||||||
|
"enum": [
|
||||||
|
"YES",
|
||||||
|
"NO"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"List-TestEnum": {
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/TestEnum"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
150
core/src/test/resources/T0077__enriched_top_level_list.json
Normal file
150
core/src/test/resources/T0077__enriched_top_level_list.json
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/example": {
|
||||||
|
"post": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A test request",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/List-TestSimpleRequest-blah-blah"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A Successful Endeavor",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/TestCreatedResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "aa",
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"deprecated": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestCreatedResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"c": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"c",
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestSimpleRequest-simple": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"deprecated": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestSimpleRequest-blah-blah": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"deprecated": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"List-TestSimpleRequest-blah-blah": {
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/TestSimpleRequest-blah-blah"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
103
core/src/test/resources/T0078__enriched_top_level_map.json
Normal file
103
core/src/test/resources/T0078__enriched_top_level_map.json
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.1.0",
|
||||||
|
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"info": {
|
||||||
|
"title": "Test API",
|
||||||
|
"version": "1.33.7",
|
||||||
|
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||||
|
"termsOfService": "https://example.com",
|
||||||
|
"contact": {
|
||||||
|
"name": "Homer Simpson",
|
||||||
|
"url": "https://gph.is/1NPUDiM",
|
||||||
|
"email": "chunkylover53@aol.com"
|
||||||
|
},
|
||||||
|
"license": {
|
||||||
|
"name": "MIT",
|
||||||
|
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "https://myawesomeapi.com",
|
||||||
|
"description": "Production instance of my API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://staging.myawesomeapi.com",
|
||||||
|
"description": "Where the fun stuff happens"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"/example": {
|
||||||
|
"get": {
|
||||||
|
"tags": [],
|
||||||
|
"summary": "Great Summary!",
|
||||||
|
"description": "testing more",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "A good response",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/Map-String-TestSimpleRequest-blah"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webhooks": {},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"TestSimpleRequest-nested": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"deprecated": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TestSimpleRequest-blah": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"a": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "A simple description"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32",
|
||||||
|
"deprecated": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Map-String-TestSimpleRequest-blah": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/TestSimpleRequest-blah"
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securitySchemes": {}
|
||||||
|
},
|
||||||
|
"security": [],
|
||||||
|
"tags": []
|
||||||
|
}
|
@ -1,54 +0,0 @@
|
|||||||
package io.bkbn.kompendium.core.fixtures
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
|
||||||
import com.google.gson.annotations.Expose
|
|
||||||
import com.google.gson.annotations.SerializedName
|
|
||||||
import io.bkbn.kompendium.json.schema.SchemaConfigurator
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
import kotlin.reflect.KProperty1
|
|
||||||
import kotlin.reflect.full.memberProperties
|
|
||||||
import kotlin.reflect.jvm.javaField
|
|
||||||
|
|
||||||
/*
|
|
||||||
These are test implementation and may well be a good starting point for creating production ones.
|
|
||||||
Both Gson and Jackson are complex and can achieve this things is more than one way therefore
|
|
||||||
these will not always work hence why they are in the test package
|
|
||||||
*/
|
|
||||||
|
|
||||||
class GsonSchemaConfigurator: SchemaConfigurator {
|
|
||||||
|
|
||||||
override fun serializableMemberProperties(clazz: KClass<*>): Collection<KProperty1<out Any, *>> {
|
|
||||||
// NOTE: This is test logic Expose is set at a global Gson level so configure to match your Gson set up
|
|
||||||
val hasAnyExpose = clazz.memberProperties.any { it.hasJavaAnnotation<Expose>() }
|
|
||||||
return if(hasAnyExpose) {
|
|
||||||
clazz.memberProperties
|
|
||||||
.filter { it.hasJavaAnnotation<Expose>() }
|
|
||||||
} else clazz.memberProperties
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun serializableName(property: KProperty1<out Any, *>): String =
|
|
||||||
property.getJavaAnnotation<SerializedName>()?.value?: property.name
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class JacksonSchemaConfigurator: SchemaConfigurator {
|
|
||||||
|
|
||||||
override fun serializableMemberProperties(clazz: KClass<*>): Collection<KProperty1<out Any, *>> =
|
|
||||||
clazz.memberProperties
|
|
||||||
.filterNot {
|
|
||||||
it.hasJavaAnnotation<JsonIgnore>()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun serializableName(property: KProperty1<out Any, *>): String =
|
|
||||||
property.getJavaAnnotation<JsonProperty>()?.value?: property.name
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified T: Annotation> KProperty1<*, *>.hasJavaAnnotation(): Boolean {
|
|
||||||
return javaField?.isAnnotationPresent(T::class.java)?: false
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified T: Annotation> KProperty1<*, *>.getJavaAnnotation(): T? {
|
|
||||||
return javaField?.getDeclaredAnnotation(T::class.java)
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package io.bkbn.kompendium.core.fixtures
|
|
||||||
|
|
||||||
enum class SupportedSerializer {
|
|
||||||
KOTLINX,
|
|
||||||
GSON,
|
|
||||||
JACKSON
|
|
||||||
}
|
|
@ -1,10 +1,9 @@
|
|||||||
package io.bkbn.kompendium.core.fixtures
|
package io.bkbn.kompendium.core.fixtures
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature
|
|
||||||
import io.bkbn.kompendium.core.fixtures.TestSpecs.defaultSpec
|
import io.bkbn.kompendium.core.fixtures.TestSpecs.defaultSpec
|
||||||
import io.bkbn.kompendium.core.plugin.NotarizedApplication
|
import io.bkbn.kompendium.core.plugin.NotarizedApplication
|
||||||
import io.bkbn.kompendium.core.routes.redoc
|
import io.bkbn.kompendium.core.routes.redoc
|
||||||
|
import io.bkbn.kompendium.core.routes.swagger
|
||||||
import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator
|
import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator
|
||||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||||
import io.bkbn.kompendium.oas.OpenApiSpec
|
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||||
@ -15,19 +14,19 @@ import io.kotest.matchers.shouldNot
|
|||||||
import io.kotest.matchers.string.beBlank
|
import io.kotest.matchers.string.beBlank
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
import io.ktor.http.ContentType
|
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.serialization.gson.gson
|
|
||||||
import io.ktor.serialization.jackson.jackson
|
|
||||||
import io.ktor.serialization.kotlinx.json.json
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.ktor.server.application.Application
|
import io.ktor.server.application.Application
|
||||||
|
import io.ktor.server.application.ServerConfigBuilder
|
||||||
|
import io.ktor.server.engine.ApplicationEnvironmentBuilder
|
||||||
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
||||||
import io.ktor.server.routing.Routing
|
import io.ktor.server.plugins.contentnegotiation.ContentNegotiationConfig
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
import io.ktor.server.testing.ApplicationTestBuilder
|
import io.ktor.server.testing.ApplicationTestBuilder
|
||||||
import io.ktor.server.testing.testApplication
|
import io.ktor.server.testing.testApplication
|
||||||
import kotlin.reflect.KType
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import kotlin.reflect.KType
|
||||||
|
|
||||||
object TestHelpers {
|
object TestHelpers {
|
||||||
private const val OPEN_API_ENDPOINT = "/openapi.json"
|
private const val OPEN_API_ENDPOINT = "/openapi.json"
|
||||||
@ -43,8 +42,8 @@ object TestHelpers {
|
|||||||
* exists as expected, and that the content matches the expected blob found in the specified file
|
* exists as expected, and that the content matches the expected blob found in the specified file
|
||||||
* @param snapshotName The snapshot file to retrieve from the resources folder
|
* @param snapshotName The snapshot file to retrieve from the resources folder
|
||||||
*/
|
*/
|
||||||
private suspend fun ApplicationTestBuilder.compareOpenAPISpec(snapshotName: String) {
|
private suspend fun ApplicationTestBuilder.compareOpenAPISpec(rootPath: String, snapshotName: String) {
|
||||||
val response = client.get(OPEN_API_ENDPOINT)
|
val response = client.get("$rootPath$OPEN_API_ENDPOINT")
|
||||||
response shouldHaveStatus HttpStatusCode.OK
|
response shouldHaveStatus HttpStatusCode.OK
|
||||||
response.bodyAsText() shouldNot beBlank()
|
response.bodyAsText() shouldNot beBlank()
|
||||||
response.bodyAsText() shouldEqualJson getFileSnapshot(snapshotName)
|
response.bodyAsText() shouldEqualJson getFileSnapshot(snapshotName)
|
||||||
@ -53,7 +52,7 @@ object TestHelpers {
|
|||||||
/**
|
/**
|
||||||
* This will take a provided JSON snapshot file, retrieve it from the resource folder,
|
* This will take a provided JSON snapshot file, retrieve it from the resource folder,
|
||||||
* and build a test ktor server to compare the expected output with the output found in the default
|
* and build a test ktor server to compare the expected output with the output found in the default
|
||||||
* OpenAPI json endpoint. By default, this will run the same test with Gson, Kotlinx, and Jackson serializers
|
* OpenAPI json endpoint.
|
||||||
* @param snapshotName The snapshot file to retrieve from the resources folder
|
* @param snapshotName The snapshot file to retrieve from the resources folder
|
||||||
*/
|
*/
|
||||||
fun openApiTestAllSerializers(
|
fun openApiTestAllSerializers(
|
||||||
@ -61,50 +60,62 @@ object TestHelpers {
|
|||||||
customTypes: Map<KType, JsonSchema> = emptyMap(),
|
customTypes: Map<KType, JsonSchema> = emptyMap(),
|
||||||
applicationSetup: Application.() -> Unit = { },
|
applicationSetup: Application.() -> Unit = { },
|
||||||
specOverrides: OpenApiSpec.() -> OpenApiSpec = { this },
|
specOverrides: OpenApiSpec.() -> OpenApiSpec = { this },
|
||||||
routeUnderTest: Routing.() -> Unit
|
applicationEnvironmentBuilder: ApplicationEnvironmentBuilder.() -> Unit = {},
|
||||||
) {
|
notarizedApplicationConfigOverrides: NotarizedApplication.Config.() -> Unit = {},
|
||||||
openApiTest(snapshotName, SupportedSerializer.KOTLINX, routeUnderTest, applicationSetup, specOverrides, customTypes)
|
contentNegotiation: ContentNegotiationConfig.() -> Unit = {
|
||||||
openApiTest(snapshotName, SupportedSerializer.JACKSON, routeUnderTest, applicationSetup, specOverrides, customTypes)
|
json(Json {
|
||||||
openApiTest(snapshotName, SupportedSerializer.GSON, routeUnderTest, applicationSetup, specOverrides, customTypes)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun openApiTest(
|
|
||||||
snapshotName: String,
|
|
||||||
serializer: SupportedSerializer,
|
|
||||||
routeUnderTest: Routing.() -> Unit,
|
|
||||||
applicationSetup: Application.() -> Unit,
|
|
||||||
specOverrides: OpenApiSpec.() -> OpenApiSpec,
|
|
||||||
typeOverrides: Map<KType, JsonSchema> = emptyMap()
|
|
||||||
) = testApplication {
|
|
||||||
install(NotarizedApplication()) {
|
|
||||||
customTypes = typeOverrides
|
|
||||||
spec = defaultSpec().specOverrides()
|
|
||||||
schemaConfigurator = when (serializer) {
|
|
||||||
SupportedSerializer.KOTLINX -> KotlinXSchemaConfigurator()
|
|
||||||
SupportedSerializer.GSON -> GsonSchemaConfigurator()
|
|
||||||
SupportedSerializer.JACKSON -> JacksonSchemaConfigurator()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
install(ContentNegotiation) {
|
|
||||||
when (serializer) {
|
|
||||||
SupportedSerializer.KOTLINX -> json(Json {
|
|
||||||
encodeDefaults = true
|
encodeDefaults = true
|
||||||
explicitNulls = false
|
explicitNulls = false
|
||||||
serializersModule = KompendiumSerializersModule.module
|
serializersModule = KompendiumSerializersModule.module
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
SupportedSerializer.GSON -> gson()
|
serverConfigSetup: ServerConfigBuilder.() -> Unit = { },
|
||||||
SupportedSerializer.JACKSON -> jackson(ContentType.Application.Json) {
|
routeUnderTest: Route.() -> Unit
|
||||||
enable(SerializationFeature.INDENT_OUTPUT)
|
) {
|
||||||
setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
openApiTest(
|
||||||
|
snapshotName,
|
||||||
|
routeUnderTest,
|
||||||
|
applicationSetup,
|
||||||
|
specOverrides,
|
||||||
|
customTypes,
|
||||||
|
notarizedApplicationConfigOverrides,
|
||||||
|
contentNegotiation,
|
||||||
|
applicationEnvironmentBuilder,
|
||||||
|
serverConfigSetup
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openApiTest(
|
||||||
|
snapshotName: String,
|
||||||
|
routeUnderTest: Route.() -> Unit,
|
||||||
|
applicationSetup: Application.() -> Unit,
|
||||||
|
specOverrides: OpenApiSpec.() -> OpenApiSpec,
|
||||||
|
typeOverrides: Map<KType, JsonSchema> = emptyMap(),
|
||||||
|
notarizedApplicationConfigOverrides: NotarizedApplication.Config.() -> Unit,
|
||||||
|
contentNegotiation: ContentNegotiationConfig.() -> Unit,
|
||||||
|
applicationBuilder: ApplicationEnvironmentBuilder.() -> Unit,
|
||||||
|
serverConfigSetup: ServerConfigBuilder.() -> Unit
|
||||||
|
) = testApplication {
|
||||||
|
environment(applicationBuilder)
|
||||||
|
install(NotarizedApplication()) {
|
||||||
|
customTypes = typeOverrides
|
||||||
|
spec = { specOverrides(defaultSpec()) }
|
||||||
|
schemaConfigurator = KotlinXSchemaConfigurator()
|
||||||
|
notarizedApplicationConfigOverrides()
|
||||||
}
|
}
|
||||||
|
install(ContentNegotiation) {
|
||||||
|
contentNegotiation()
|
||||||
}
|
}
|
||||||
application(applicationSetup)
|
application(applicationSetup)
|
||||||
|
serverConfig(serverConfigSetup)
|
||||||
routing {
|
routing {
|
||||||
|
swagger()
|
||||||
redoc()
|
redoc()
|
||||||
routeUnderTest()
|
routeUnderTest()
|
||||||
}
|
}
|
||||||
compareOpenAPISpec(snapshotName)
|
|
||||||
|
val root = ServerConfigBuilder(ApplicationEnvironmentBuilder().apply(applicationBuilder).build()).apply(serverConfigSetup).rootPath
|
||||||
|
compareOpenAPISpec(root, snapshotName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package io.bkbn.kompendium.core.fixtures
|
package io.bkbn.kompendium.core.fixtures
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
|
||||||
import com.google.gson.annotations.Expose
|
|
||||||
import com.google.gson.annotations.SerializedName
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
|
import kotlinx.serialization.encodeToString
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class TestNested(val nesty: String)
|
data class TestNested(val nesty: String)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class DoubleResponse(val payload: Double)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class TestRequest(
|
data class TestRequest(
|
||||||
val fieldName: TestNested,
|
val fieldName: TestNested,
|
||||||
@ -88,6 +89,25 @@ data class AnothaJamma(val b: Float) : SlammaJamma
|
|||||||
|
|
||||||
data class InsaneJamma(val c: SlammaJamma) : SlammaJamma
|
data class InsaneJamma(val c: SlammaJamma) : SlammaJamma
|
||||||
|
|
||||||
|
sealed interface ChillaxificationMaximization
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
@SerialName("chillax")
|
||||||
|
data class Chillax(val a: String) : ChillaxificationMaximization
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
@SerialName("maximize")
|
||||||
|
data class ToDaMax(val b: Int) : ChillaxificationMaximization
|
||||||
|
|
||||||
|
sealed class Gadget(
|
||||||
|
open val title: String,
|
||||||
|
open val description: String
|
||||||
|
)
|
||||||
|
|
||||||
|
class Gizmo(
|
||||||
|
override val title: String,
|
||||||
|
) : Gadget(title, "Just a gizmo")
|
||||||
|
|
||||||
sealed interface Flibbity<T>
|
sealed interface Flibbity<T>
|
||||||
|
|
||||||
data class Gibbity<T>(val a: T) : Flibbity<T>
|
data class Gibbity<T>(val a: T) : Flibbity<T>
|
||||||
@ -155,15 +175,13 @@ object Nested {
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class TransientObject(
|
data class TransientObject(
|
||||||
@field:Expose
|
|
||||||
val nonTransient: String,
|
val nonTransient: String,
|
||||||
@field:JsonIgnore
|
|
||||||
@Transient
|
@Transient
|
||||||
val transient: String = "transient"
|
val transient: String = "transient"
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UnbakcedObject(
|
data class UnbackedObject(
|
||||||
val backed: String
|
val backed: String
|
||||||
) {
|
) {
|
||||||
val unbacked: String get() = "unbacked"
|
val unbacked: String get() = "unbacked"
|
||||||
@ -171,8 +189,26 @@ data class UnbakcedObject(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SerialNameObject(
|
data class SerialNameObject(
|
||||||
@field:JsonProperty("snake_case_name")
|
|
||||||
@field:SerializedName("snake_case_name")
|
|
||||||
@SerialName("snake_case_name")
|
@SerialName("snake_case_name")
|
||||||
val camelCaseName: String
|
val camelCaseName: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class GenericObject<T>(
|
||||||
|
val data: T
|
||||||
|
)
|
||||||
|
|
||||||
|
enum class Color {
|
||||||
|
RED,
|
||||||
|
GREEN,
|
||||||
|
BLUE
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ObjectWithEnum(
|
||||||
|
val color: Color
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SomethingSimilar(val a: String) {
|
||||||
|
val b = "something else"
|
||||||
|
}
|
||||||
|
@ -5,8 +5,8 @@ complexity:
|
|||||||
active: true
|
active: true
|
||||||
functionThreshold: 10
|
functionThreshold: 10
|
||||||
constructorThreshold: 15
|
constructorThreshold: 15
|
||||||
ComplexMethod:
|
CyclomaticComplexMethod:
|
||||||
threshold: 20
|
threshold: 15
|
||||||
style:
|
style:
|
||||||
MaxLineLength:
|
MaxLineLength:
|
||||||
excludes: ['**/test/**/*']
|
excludes: ['**/test/**/*']
|
||||||
@ -22,6 +22,8 @@ formatting:
|
|||||||
indentSize: 2
|
indentSize: 2
|
||||||
ImportOrdering:
|
ImportOrdering:
|
||||||
active: false
|
active: false
|
||||||
|
EnumEntryNameCase:
|
||||||
|
active: false
|
||||||
naming:
|
naming:
|
||||||
ConstructorParameterNaming:
|
ConstructorParameterNaming:
|
||||||
active: false
|
active: false
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user