@goast/kotlin 0.5.14 → 0.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +45 -45
- package/assets/client/okhttp3/ApiAbstractions.kt +30 -30
- package/assets/client/okhttp3/ApiClient.kt +252 -252
- package/assets/client/okhttp3/ApiResponse.kt +43 -43
- package/assets/client/okhttp3/Errors.kt +21 -21
- package/assets/client/okhttp3/PartConfig.kt +11 -11
- package/assets/client/okhttp3/RequestConfig.kt +18 -18
- package/assets/client/okhttp3/RequestMethod.kt +8 -8
- package/assets/client/okhttp3/ResponseExtensions.kt +24 -24
- package/assets/client/spring-reactive-web-clients/ApiRequestFile.kt +33 -33
- package/esm/src/generators/models/model-generator.d.ts.map +1 -1
- package/esm/src/generators/models/model-generator.js +5 -14
- package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +40 -47
- package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +9 -9
- package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
- package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +32 -42
- package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +16 -25
- package/esm/src/utils.d.ts +1 -3
- package/esm/src/utils.d.ts.map +1 -1
- package/esm/src/utils.js +0 -7
- package/package.json +2 -2
- package/script/src/generators/models/model-generator.d.ts.map +1 -1
- package/script/src/generators/models/model-generator.js +4 -13
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +39 -46
- package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +9 -9
- package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
- package/script/src/generators/services/spring-controllers/spring-controller-generator.js +31 -41
- package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +15 -24
- package/script/src/utils.d.ts +1 -3
- package/script/src/utils.d.ts.map +1 -1
- package/script/src/utils.js +0 -9
- package/src/mod.ts +0 -8
- package/src/src/assets.ts +0 -9
- package/src/src/ast/_index.ts +0 -66
- package/src/src/ast/common.ts +0 -1
- package/src/src/ast/index.ts +0 -1
- package/src/src/ast/node.ts +0 -10
- package/src/src/ast/nodes/annotation.ts +0 -79
- package/src/src/ast/nodes/argument.ts +0 -62
- package/src/src/ast/nodes/call.ts +0 -75
- package/src/src/ast/nodes/class.ts +0 -178
- package/src/src/ast/nodes/collection-literal.ts +0 -49
- package/src/src/ast/nodes/constructor.ts +0 -126
- package/src/src/ast/nodes/doc-tag.ts +0 -138
- package/src/src/ast/nodes/doc.ts +0 -111
- package/src/src/ast/nodes/enum-value.ts +0 -100
- package/src/src/ast/nodes/enum.ts +0 -163
- package/src/src/ast/nodes/function.ts +0 -178
- package/src/src/ast/nodes/generic-parameter.ts +0 -54
- package/src/src/ast/nodes/init-block.ts +0 -38
- package/src/src/ast/nodes/interface.ts +0 -133
- package/src/src/ast/nodes/lambda-type.ts +0 -73
- package/src/src/ast/nodes/lambda.ts +0 -74
- package/src/src/ast/nodes/object.ts +0 -102
- package/src/src/ast/nodes/parameter.ts +0 -118
- package/src/src/ast/nodes/property.ts +0 -225
- package/src/src/ast/nodes/reference.ts +0 -178
- package/src/src/ast/nodes/string.ts +0 -114
- package/src/src/ast/nodes/types.ts +0 -23
- package/src/src/ast/references/index.ts +0 -10
- package/src/src/ast/references/jackson.ts +0 -59
- package/src/src/ast/references/jakarta.ts +0 -14
- package/src/src/ast/references/java.ts +0 -27
- package/src/src/ast/references/kotlin.ts +0 -41
- package/src/src/ast/references/kotlinx.ts +0 -14
- package/src/src/ast/references/okhttp3.ts +0 -5
- package/src/src/ast/references/reactor.ts +0 -5
- package/src/src/ast/references/spring-reactive.ts +0 -37
- package/src/src/ast/references/spring.ts +0 -86
- package/src/src/ast/references/swagger.ts +0 -23
- package/src/src/ast/utils/get-kotlin-builder-options.ts +0 -19
- package/src/src/ast/utils/to-kt-node.ts +0 -31
- package/src/src/ast/utils/write-kt-annotations.ts +0 -15
- package/src/src/ast/utils/write-kt-arguments.ts +0 -45
- package/src/src/ast/utils/write-kt-enum-values.ts +0 -27
- package/src/src/ast/utils/write-kt-generic-parameters.ts +0 -12
- package/src/src/ast/utils/write-kt-members.ts +0 -25
- package/src/src/ast/utils/write-kt-node.ts +0 -37
- package/src/src/ast/utils/write-kt-parameters.ts +0 -25
- package/src/src/common-results.ts +0 -4
- package/src/src/config.ts +0 -61
- package/src/src/file-builder.ts +0 -112
- package/src/src/generators/file-generator.ts +0 -29
- package/src/src/generators/index.ts +0 -5
- package/src/src/generators/models/args.ts +0 -136
- package/src/src/generators/models/index.ts +0 -4
- package/src/src/generators/models/model-generator.ts +0 -736
- package/src/src/generators/models/models-generator.ts +0 -65
- package/src/src/generators/models/models.ts +0 -95
- package/src/src/generators/services/okhttp3-clients/args.ts +0 -90
- package/src/src/generators/services/okhttp3-clients/index.ts +0 -4
- package/src/src/generators/services/okhttp3-clients/models.ts +0 -73
- package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +0 -627
- package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +0 -188
- package/src/src/generators/services/okhttp3-clients/refs.ts +0 -59
- package/src/src/generators/services/spring-controllers/args.ts +0 -95
- package/src/src/generators/services/spring-controllers/index.ts +0 -4
- package/src/src/generators/services/spring-controllers/models.ts +0 -76
- package/src/src/generators/services/spring-controllers/refs.ts +0 -17
- package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +0 -1122
- package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +0 -140
- package/src/src/generators/services/spring-reactive-web-clients/args.ts +0 -112
- package/src/src/generators/services/spring-reactive-web-clients/index.ts +0 -4
- package/src/src/generators/services/spring-reactive-web-clients/models.ts +0 -78
- package/src/src/generators/services/spring-reactive-web-clients/refs.ts +0 -11
- package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts +0 -641
- package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts +0 -125
- package/src/src/import-collection.ts +0 -98
- package/src/src/types.ts +0 -3
- package/src/src/utils.ts +0 -55
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Marc Schmidt
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Marc Schmidt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
# gOAst (@goast/kotlin)
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@goast/kotlin)
|
|
4
|
-
[](https://jsr.io/@goast/kotlin)
|
|
5
|
-
|
|
6
|
-
**gOAst** stands for **g**enerative **O**pen **A**PI **s**pecification **t**ransformer, a tool designed to transform
|
|
7
|
-
OpenAPI specifications into various forms with flexibility and extensibility at its core.
|
|
8
|
-
|
|
9
|
-
For more Information, please visit the [gOAst GitHub Repository](https://github.com/MaSch0212/goast/blob/main).
|
|
10
|
-
|
|
11
|
-
## Purpose 👍
|
|
12
|
-
|
|
13
|
-
The `@goast/kotlin` package provides generators for [Kotlin](https://kotlinlang.org/) code generation from OpenAPI
|
|
14
|
-
specifications.
|
|
15
|
-
|
|
16
|
-
## Usage Example 🚀
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
import { OpenApiGenerator } from '@goast/core';
|
|
20
|
-
import { KotlinModelsGenerator, KotlinSpringControllersGenerator } from '@goast/kotlin';
|
|
21
|
-
|
|
22
|
-
async function main() {
|
|
23
|
-
await new OpenApiGenerator({ outputDir: '.api' })
|
|
24
|
-
.useType(KotlinModelsGenerator)
|
|
25
|
-
.useType(KotlinSpringControllersGenerator)
|
|
26
|
-
.parseAndGenerateFromDir('.openapi');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
main();
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Available Generators 📚
|
|
33
|
-
|
|
34
|
-
- [`KotlinModelsGenerator`](https://github.com/MaSch0212/goast/wiki/Kotlin%20Models%20Generator): Generates Kotlin data
|
|
35
|
-
classes from schemas in the OpenAPI specification(s).
|
|
36
|
-
- [`KotlinSpringControllersGenerator`](https://github.com/MaSch0212/goast/wiki/Kotlin%20Spring%20Controllers%20Generator):
|
|
37
|
-
Generates [Spring](https://spring.io/) controllers for Kotlin from paths in the OpenAPI specification(s).
|
|
38
|
-
- Depends on the output of the `KotlinModelsGenerator` generator.
|
|
39
|
-
- [`KotlinOkHttp3ClientsGenerator`](https://github.com/MaSch0212/goast/wiki/Kotlin%20OkHttp3%20Clients%20Generator):
|
|
40
|
-
Generates [OkHttp3](https://square.github.io/okhttp/) clients for Kotlin from paths in the OpenAPI specification(s).
|
|
41
|
-
- Depends on the output of the `KotlinModelsGenerator` generator.
|
|
42
|
-
|
|
43
|
-
## API Documentation 📖
|
|
44
|
-
|
|
45
|
-
The API documentation can be found [here](https://github.com/MaSch0212/goast/wiki/Kotlin%20Generators).
|
|
1
|
+
# gOAst (@goast/kotlin)
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@goast/kotlin)
|
|
4
|
+
[](https://jsr.io/@goast/kotlin)
|
|
5
|
+
|
|
6
|
+
**gOAst** stands for **g**enerative **O**pen **A**PI **s**pecification **t**ransformer, a tool designed to transform
|
|
7
|
+
OpenAPI specifications into various forms with flexibility and extensibility at its core.
|
|
8
|
+
|
|
9
|
+
For more Information, please visit the [gOAst GitHub Repository](https://github.com/MaSch0212/goast/blob/main).
|
|
10
|
+
|
|
11
|
+
## Purpose 👍
|
|
12
|
+
|
|
13
|
+
The `@goast/kotlin` package provides generators for [Kotlin](https://kotlinlang.org/) code generation from OpenAPI
|
|
14
|
+
specifications.
|
|
15
|
+
|
|
16
|
+
## Usage Example 🚀
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { OpenApiGenerator } from '@goast/core';
|
|
20
|
+
import { KotlinModelsGenerator, KotlinSpringControllersGenerator } from '@goast/kotlin';
|
|
21
|
+
|
|
22
|
+
async function main() {
|
|
23
|
+
await new OpenApiGenerator({ outputDir: '.api' })
|
|
24
|
+
.useType(KotlinModelsGenerator)
|
|
25
|
+
.useType(KotlinSpringControllersGenerator)
|
|
26
|
+
.parseAndGenerateFromDir('.openapi');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Available Generators 📚
|
|
33
|
+
|
|
34
|
+
- [`KotlinModelsGenerator`](https://github.com/MaSch0212/goast/wiki/Kotlin%20Models%20Generator): Generates Kotlin data
|
|
35
|
+
classes from schemas in the OpenAPI specification(s).
|
|
36
|
+
- [`KotlinSpringControllersGenerator`](https://github.com/MaSch0212/goast/wiki/Kotlin%20Spring%20Controllers%20Generator):
|
|
37
|
+
Generates [Spring](https://spring.io/) controllers for Kotlin from paths in the OpenAPI specification(s).
|
|
38
|
+
- Depends on the output of the `KotlinModelsGenerator` generator.
|
|
39
|
+
- [`KotlinOkHttp3ClientsGenerator`](https://github.com/MaSch0212/goast/wiki/Kotlin%20OkHttp3%20Clients%20Generator):
|
|
40
|
+
Generates [OkHttp3](https://square.github.io/okhttp/) clients for Kotlin from paths in the OpenAPI specification(s).
|
|
41
|
+
- Depends on the output of the `KotlinModelsGenerator` generator.
|
|
42
|
+
|
|
43
|
+
## API Documentation 📖
|
|
44
|
+
|
|
45
|
+
The API documentation can be found [here](https://github.com/MaSch0212/goast/wiki/Kotlin%20Generators).
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
typealias MultiValueMap = MutableMap<String, List<String>>
|
|
4
|
-
|
|
5
|
-
fun collectionDelimiter(collectionFormat: String) = when (collectionFormat) {
|
|
6
|
-
"csv" -> ","
|
|
7
|
-
"tsv" -> "\t"
|
|
8
|
-
"pipe" -> "|"
|
|
9
|
-
"space" -> " "
|
|
10
|
-
else -> ""
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
|
14
|
-
|
|
15
|
-
fun <T : Any?> toMultiValue(
|
|
16
|
-
items: Array<T>,
|
|
17
|
-
collectionFormat: String,
|
|
18
|
-
map: (item: T) -> String = defaultMultiValueConverter
|
|
19
|
-
) = toMultiValue(items.asIterable(), collectionFormat, map)
|
|
20
|
-
|
|
21
|
-
fun <T : Any?> toMultiValue(
|
|
22
|
-
items: Iterable<T>,
|
|
23
|
-
collectionFormat: String,
|
|
24
|
-
map: (item: T) -> String = defaultMultiValueConverter
|
|
25
|
-
): List<String> {
|
|
26
|
-
return when (collectionFormat) {
|
|
27
|
-
"multi" -> items.map(map)
|
|
28
|
-
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
typealias MultiValueMap = MutableMap<String, List<String>>
|
|
4
|
+
|
|
5
|
+
fun collectionDelimiter(collectionFormat: String) = when (collectionFormat) {
|
|
6
|
+
"csv" -> ","
|
|
7
|
+
"tsv" -> "\t"
|
|
8
|
+
"pipe" -> "|"
|
|
9
|
+
"space" -> " "
|
|
10
|
+
else -> ""
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
|
14
|
+
|
|
15
|
+
fun <T : Any?> toMultiValue(
|
|
16
|
+
items: Array<T>,
|
|
17
|
+
collectionFormat: String,
|
|
18
|
+
map: (item: T) -> String = defaultMultiValueConverter
|
|
19
|
+
) = toMultiValue(items.asIterable(), collectionFormat, map)
|
|
20
|
+
|
|
21
|
+
fun <T : Any?> toMultiValue(
|
|
22
|
+
items: Iterable<T>,
|
|
23
|
+
collectionFormat: String,
|
|
24
|
+
map: (item: T) -> String = defaultMultiValueConverter
|
|
25
|
+
): List<String> {
|
|
26
|
+
return when (collectionFormat) {
|
|
27
|
+
"multi" -> items.map(map)
|
|
28
|
+
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
|
|
29
|
+
}
|
|
30
|
+
}
|