@goast/kotlin 0.5.9-beta.2 → 0.5.9
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/assets/client/okhttp3/ApiAbstractions.kt +30 -30
- package/assets/client/okhttp3/ApiClient.kt +253 -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/ast/references/jackson.d.ts +5 -8
- package/esm/src/ast/references/jackson.d.ts.map +1 -1
- package/esm/src/ast/references/jackson.js +6 -14
- package/esm/src/config.d.ts +0 -10
- package/esm/src/config.d.ts.map +1 -1
- package/esm/src/config.js +0 -1
- 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 +32 -36
- package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts.map +1 -1
- package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +6 -22
- package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts +11 -11
- 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 +19 -27
- 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 +1 -4
- package/package.json +1 -1
- package/script/src/ast/references/jackson.d.ts +5 -8
- package/script/src/ast/references/jackson.d.ts.map +1 -1
- package/script/src/ast/references/jackson.js +7 -20
- package/script/src/config.d.ts +0 -10
- package/script/src/config.d.ts.map +1 -1
- package/script/src/config.js +0 -1
- 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 +32 -36
- package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts.map +1 -1
- package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +6 -22
- package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts +11 -11
- 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 +19 -27
- 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 +1 -4
- package/src/mod.ts +8 -0
- package/src/src/assets.ts +9 -0
- package/src/src/ast/_index.ts +66 -0
- package/src/src/ast/common.ts +1 -0
- package/src/src/ast/index.ts +1 -0
- package/src/src/ast/node.ts +10 -0
- package/src/src/ast/nodes/annotation.ts +79 -0
- package/src/src/ast/nodes/argument.ts +62 -0
- package/src/src/ast/nodes/call.ts +75 -0
- package/src/src/ast/nodes/class.ts +178 -0
- package/src/src/ast/nodes/collection-literal.ts +49 -0
- package/src/src/ast/nodes/constructor.ts +126 -0
- package/src/src/ast/nodes/doc-tag.ts +138 -0
- package/src/src/ast/nodes/doc.ts +111 -0
- package/src/src/ast/nodes/enum-value.ts +100 -0
- package/src/src/ast/nodes/enum.ts +163 -0
- package/src/src/ast/nodes/function.ts +178 -0
- package/src/src/ast/nodes/generic-parameter.ts +54 -0
- package/src/src/ast/nodes/init-block.ts +38 -0
- package/src/src/ast/nodes/interface.ts +133 -0
- package/src/src/ast/nodes/lambda-type.ts +73 -0
- package/src/src/ast/nodes/lambda.ts +74 -0
- package/src/src/ast/nodes/object.ts +102 -0
- package/src/src/ast/nodes/parameter.ts +118 -0
- package/src/src/ast/nodes/property.ts +225 -0
- package/src/src/ast/nodes/reference.ts +178 -0
- package/src/src/ast/nodes/string.ts +114 -0
- package/src/src/ast/nodes/types.ts +23 -0
- package/src/src/ast/references/index.ts +10 -0
- package/src/src/ast/references/jackson.ts +44 -0
- package/src/src/ast/references/jakarta.ts +14 -0
- package/src/src/ast/references/java.ts +27 -0
- package/src/src/ast/references/kotlin.ts +41 -0
- package/src/src/ast/references/kotlinx.ts +14 -0
- package/src/src/ast/references/okhttp3.ts +5 -0
- package/src/src/ast/references/reactor.ts +5 -0
- package/src/src/ast/references/spring-reactive.ts +33 -0
- package/src/src/ast/references/spring.ts +86 -0
- package/src/src/ast/references/swagger.ts +23 -0
- package/src/src/ast/utils/get-kotlin-builder-options.ts +19 -0
- package/src/src/ast/utils/to-kt-node.ts +31 -0
- package/src/src/ast/utils/write-kt-annotations.ts +15 -0
- package/src/src/ast/utils/write-kt-arguments.ts +45 -0
- package/src/src/ast/utils/write-kt-enum-values.ts +27 -0
- package/src/src/ast/utils/write-kt-generic-parameters.ts +12 -0
- package/src/src/ast/utils/write-kt-members.ts +25 -0
- package/src/src/ast/utils/write-kt-node.ts +37 -0
- package/src/src/ast/utils/write-kt-parameters.ts +25 -0
- package/src/src/common-results.ts +4 -0
- package/src/src/config.ts +48 -0
- package/src/src/file-builder.ts +112 -0
- package/src/src/generators/file-generator.ts +29 -0
- package/src/src/generators/index.ts +5 -0
- package/src/src/generators/models/args.ts +136 -0
- package/src/src/generators/models/index.ts +4 -0
- package/src/src/generators/models/model-generator.ts +725 -0
- package/src/src/generators/models/models-generator.ts +65 -0
- package/src/src/generators/models/models.ts +95 -0
- package/src/src/generators/services/okhttp3-clients/args.ts +90 -0
- package/src/src/generators/services/okhttp3-clients/index.ts +4 -0
- package/src/src/generators/services/okhttp3-clients/models.ts +73 -0
- package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +609 -0
- package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +169 -0
- package/src/src/generators/services/okhttp3-clients/refs.ts +59 -0
- package/src/src/generators/services/spring-controllers/args.ts +95 -0
- package/src/src/generators/services/spring-controllers/index.ts +4 -0
- package/src/src/generators/services/spring-controllers/models.ts +76 -0
- package/src/src/generators/services/spring-controllers/refs.ts +17 -0
- package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +1099 -0
- package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +140 -0
- package/src/src/generators/services/spring-reactive-web-clients/args.ts +103 -0
- package/src/src/generators/services/spring-reactive-web-clients/index.ts +4 -0
- package/src/src/generators/services/spring-reactive-web-clients/models.ts +62 -0
- package/src/src/generators/services/spring-reactive-web-clients/refs.ts +11 -0
- package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts +583 -0
- package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts +125 -0
- package/src/src/import-collection.ts +98 -0
- package/src/src/types.ts +3 -0
- package/src/src/utils.ts +47 -0
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
enum class ResponseType {
|
|
4
|
-
Success, Informational, Redirection, ClientError, ServerError
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface Response
|
|
8
|
-
|
|
9
|
-
abstract class ApiResponse<T>(val responseType: ResponseType) : Response {
|
|
10
|
-
abstract val statusCode: Int
|
|
11
|
-
abstract val headers: Map<String, List<String>>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class Success<T>(
|
|
15
|
-
val data: T,
|
|
16
|
-
override val statusCode: Int = -1,
|
|
17
|
-
override val headers: Map<String, List<String>> = mapOf()
|
|
18
|
-
) : ApiResponse<T>(ResponseType.Success)
|
|
19
|
-
|
|
20
|
-
class Informational<T>(
|
|
21
|
-
val statusText: String,
|
|
22
|
-
override val statusCode: Int = -1,
|
|
23
|
-
override val headers: Map<String, List<String>> = mapOf()
|
|
24
|
-
) : ApiResponse<T>(ResponseType.Informational)
|
|
25
|
-
|
|
26
|
-
class Redirection<T>(
|
|
27
|
-
override val statusCode: Int = -1,
|
|
28
|
-
override val headers: Map<String, List<String>> = mapOf()
|
|
29
|
-
) : ApiResponse<T>(ResponseType.Redirection)
|
|
30
|
-
|
|
31
|
-
class ClientError<T>(
|
|
32
|
-
val message: String? = null,
|
|
33
|
-
val body: Any? = null,
|
|
34
|
-
override val statusCode: Int = -1,
|
|
35
|
-
override val headers: Map<String, List<String>> = mapOf()
|
|
36
|
-
) : ApiResponse<T>(ResponseType.ClientError)
|
|
37
|
-
|
|
38
|
-
class ServerError<T>(
|
|
39
|
-
val message: String? = null,
|
|
40
|
-
val body: Any? = null,
|
|
41
|
-
override val statusCode: Int = -1,
|
|
42
|
-
override val headers: Map<String, List<String>>
|
|
43
|
-
) : ApiResponse<T>(ResponseType.ServerError)
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
enum class ResponseType {
|
|
4
|
+
Success, Informational, Redirection, ClientError, ServerError
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Response
|
|
8
|
+
|
|
9
|
+
abstract class ApiResponse<T>(val responseType: ResponseType) : Response {
|
|
10
|
+
abstract val statusCode: Int
|
|
11
|
+
abstract val headers: Map<String, List<String>>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class Success<T>(
|
|
15
|
+
val data: T,
|
|
16
|
+
override val statusCode: Int = -1,
|
|
17
|
+
override val headers: Map<String, List<String>> = mapOf()
|
|
18
|
+
) : ApiResponse<T>(ResponseType.Success)
|
|
19
|
+
|
|
20
|
+
class Informational<T>(
|
|
21
|
+
val statusText: String,
|
|
22
|
+
override val statusCode: Int = -1,
|
|
23
|
+
override val headers: Map<String, List<String>> = mapOf()
|
|
24
|
+
) : ApiResponse<T>(ResponseType.Informational)
|
|
25
|
+
|
|
26
|
+
class Redirection<T>(
|
|
27
|
+
override val statusCode: Int = -1,
|
|
28
|
+
override val headers: Map<String, List<String>> = mapOf()
|
|
29
|
+
) : ApiResponse<T>(ResponseType.Redirection)
|
|
30
|
+
|
|
31
|
+
class ClientError<T>(
|
|
32
|
+
val message: String? = null,
|
|
33
|
+
val body: Any? = null,
|
|
34
|
+
override val statusCode: Int = -1,
|
|
35
|
+
override val headers: Map<String, List<String>> = mapOf()
|
|
36
|
+
) : ApiResponse<T>(ResponseType.ClientError)
|
|
37
|
+
|
|
38
|
+
class ServerError<T>(
|
|
39
|
+
val message: String? = null,
|
|
40
|
+
val body: Any? = null,
|
|
41
|
+
override val statusCode: Int = -1,
|
|
42
|
+
override val headers: Map<String, List<String>>
|
|
43
|
+
) : ApiResponse<T>(ResponseType.ServerError)
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
@file:Suppress("unused")
|
|
2
|
-
|
|
3
|
-
package @PACKAGE_NAME@
|
|
4
|
-
|
|
5
|
-
import java.lang.RuntimeException
|
|
6
|
-
|
|
7
|
-
open class ClientException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) :
|
|
8
|
-
RuntimeException(message) {
|
|
9
|
-
|
|
10
|
-
companion object {
|
|
11
|
-
private const val serialVersionUID: Long = 123L
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
open class ServerException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) :
|
|
16
|
-
RuntimeException(message) {
|
|
17
|
-
|
|
18
|
-
companion object {
|
|
19
|
-
private const val serialVersionUID: Long = 456L
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
@file:Suppress("unused")
|
|
2
|
+
|
|
3
|
+
package @PACKAGE_NAME@
|
|
4
|
+
|
|
5
|
+
import java.lang.RuntimeException
|
|
6
|
+
|
|
7
|
+
open class ClientException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) :
|
|
8
|
+
RuntimeException(message) {
|
|
9
|
+
|
|
10
|
+
companion object {
|
|
11
|
+
private const val serialVersionUID: Long = 123L
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
open class ServerException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) :
|
|
16
|
+
RuntimeException(message) {
|
|
17
|
+
|
|
18
|
+
companion object {
|
|
19
|
+
private const val serialVersionUID: Long = 456L
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Defines a config object for a given part of a multi-part request.
|
|
5
|
-
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
|
6
|
-
* multi-valued headers as csv-only.
|
|
7
|
-
*/
|
|
8
|
-
data class PartConfig<T>(
|
|
9
|
-
val headers: MutableMap<String, String> = mutableMapOf(),
|
|
10
|
-
val body: T? = null
|
|
11
|
-
)
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defines a config object for a given part of a multi-part request.
|
|
5
|
+
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
|
6
|
+
* multi-valued headers as csv-only.
|
|
7
|
+
*/
|
|
8
|
+
data class PartConfig<T>(
|
|
9
|
+
val headers: MutableMap<String, String> = mutableMapOf(),
|
|
10
|
+
val body: T? = null
|
|
11
|
+
)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Defines a config object for a given request.
|
|
5
|
-
* NOTE: This object doesn't include 'body' because it
|
|
6
|
-
* allows for caching of the constructed object
|
|
7
|
-
* for many request definitions.
|
|
8
|
-
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
|
9
|
-
* multi-valued headers as csv-only.
|
|
10
|
-
*/
|
|
11
|
-
data class RequestConfig<T>(
|
|
12
|
-
val method: RequestMethod,
|
|
13
|
-
val path: String,
|
|
14
|
-
val headers: MutableMap<String, String> = mutableMapOf(),
|
|
15
|
-
val query: MutableMap<String, List<String>> = mutableMapOf(),
|
|
16
|
-
val requiresAuthentication: Boolean,
|
|
17
|
-
val body: T? = null
|
|
18
|
-
)
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defines a config object for a given request.
|
|
5
|
+
* NOTE: This object doesn't include 'body' because it
|
|
6
|
+
* allows for caching of the constructed object
|
|
7
|
+
* for many request definitions.
|
|
8
|
+
* NOTE: Headers is a Map<String,String> because rfc2616 defines
|
|
9
|
+
* multi-valued headers as csv-only.
|
|
10
|
+
*/
|
|
11
|
+
data class RequestConfig<T>(
|
|
12
|
+
val method: RequestMethod,
|
|
13
|
+
val path: String,
|
|
14
|
+
val headers: MutableMap<String, String> = mutableMapOf(),
|
|
15
|
+
val query: MutableMap<String, List<String>> = mutableMapOf(),
|
|
16
|
+
val requiresAuthentication: Boolean,
|
|
17
|
+
val body: T? = null
|
|
18
|
+
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Provides enumerated HTTP verbs
|
|
5
|
-
*/
|
|
6
|
-
enum class RequestMethod {
|
|
7
|
-
GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
|
|
8
|
-
}
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Provides enumerated HTTP verbs
|
|
5
|
+
*/
|
|
6
|
+
enum class RequestMethod {
|
|
7
|
+
GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
|
|
8
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
import okhttp3.Response
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Provides an extension to evaluation whether the response is a 1xx code
|
|
7
|
-
*/
|
|
8
|
-
val Response.isInformational: Boolean get() = this.code in 100..199
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Provides an extension to evaluation whether the response is a 3xx code
|
|
12
|
-
*/
|
|
13
|
-
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
|
14
|
-
val Response.isRedirect: Boolean get() = this.code in 300..399
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Provides an extension to evaluation whether the response is a 4xx code
|
|
18
|
-
*/
|
|
19
|
-
val Response.isClientError: Boolean get() = this.code in 400..499
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code
|
|
23
|
-
*/
|
|
24
|
-
val Response.isServerError: Boolean get() = this.code in 500..999
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
import okhttp3.Response
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides an extension to evaluation whether the response is a 1xx code
|
|
7
|
+
*/
|
|
8
|
+
val Response.isInformational: Boolean get() = this.code in 100..199
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Provides an extension to evaluation whether the response is a 3xx code
|
|
12
|
+
*/
|
|
13
|
+
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
|
14
|
+
val Response.isRedirect: Boolean get() = this.code in 300..399
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Provides an extension to evaluation whether the response is a 4xx code
|
|
18
|
+
*/
|
|
19
|
+
val Response.isClientError: Boolean get() = this.code in 400..499
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code
|
|
23
|
+
*/
|
|
24
|
+
val Response.isServerError: Boolean get() = this.code in 500..999
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
package @PACKAGE_NAME@
|
|
2
|
-
|
|
3
|
-
import org.springframework.core.io.buffer.DataBuffer
|
|
4
|
-
import org.springframework.http.MediaType
|
|
5
|
-
import org.springframework.http.client.MultipartBodyBuilder
|
|
6
|
-
import org.springframework.http.codec.multipart.FilePart
|
|
7
|
-
import java.io.File
|
|
8
|
-
|
|
9
|
-
interface ApiRequestFile {
|
|
10
|
-
companion object {
|
|
11
|
-
fun from(file: File): ApiRequestFile =
|
|
12
|
-
object : ApiRequestFile {
|
|
13
|
-
override fun addToBuilder(builder: MultipartBodyBuilder) {
|
|
14
|
-
builder
|
|
15
|
-
.part("file", file)
|
|
16
|
-
.filename(file.name)
|
|
17
|
-
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
fun from(filePart: FilePart): ApiRequestFile =
|
|
22
|
-
object : ApiRequestFile {
|
|
23
|
-
override fun addToBuilder(builder: MultipartBodyBuilder) {
|
|
24
|
-
builder
|
|
25
|
-
.asyncPart("file", filePart.content(), DataBuffer::class.java)
|
|
26
|
-
.filename(filePart.filename())
|
|
27
|
-
.contentType(filePart.headers().contentType ?: MediaType.APPLICATION_OCTET_STREAM)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fun addToBuilder(builder: MultipartBodyBuilder)
|
|
33
|
-
}
|
|
1
|
+
package @PACKAGE_NAME@
|
|
2
|
+
|
|
3
|
+
import org.springframework.core.io.buffer.DataBuffer
|
|
4
|
+
import org.springframework.http.MediaType
|
|
5
|
+
import org.springframework.http.client.MultipartBodyBuilder
|
|
6
|
+
import org.springframework.http.codec.multipart.FilePart
|
|
7
|
+
import java.io.File
|
|
8
|
+
|
|
9
|
+
interface ApiRequestFile {
|
|
10
|
+
companion object {
|
|
11
|
+
fun from(file: File): ApiRequestFile =
|
|
12
|
+
object : ApiRequestFile {
|
|
13
|
+
override fun addToBuilder(builder: MultipartBodyBuilder) {
|
|
14
|
+
builder
|
|
15
|
+
.part("file", file)
|
|
16
|
+
.filename(file.name)
|
|
17
|
+
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun from(filePart: FilePart): ApiRequestFile =
|
|
22
|
+
object : ApiRequestFile {
|
|
23
|
+
override fun addToBuilder(builder: MultipartBodyBuilder) {
|
|
24
|
+
builder
|
|
25
|
+
.asyncPart("file", filePart.content(), DataBuffer::class.java)
|
|
26
|
+
.filename(filePart.filename())
|
|
27
|
+
.contentType(filePart.headers().contentType ?: MediaType.APPLICATION_OCTET_STREAM)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fun addToBuilder(builder: MultipartBodyBuilder)
|
|
33
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { SpringBootVersion } from '../../config.js';
|
|
3
|
-
import { type KtReference, type KtReferenceFactory } from '../nodes/reference.js';
|
|
1
|
+
import { type KtReferenceFactory } from '../nodes/reference.js';
|
|
4
2
|
export declare const jsonTypeInfo: KtReferenceFactory;
|
|
5
3
|
export declare const jsonSubTypes: KtReferenceFactory;
|
|
6
4
|
export declare const jsonClassDescription: KtReferenceFactory;
|
|
@@ -10,9 +8,8 @@ export declare const jsonInclude: KtReferenceFactory;
|
|
|
10
8
|
export declare const jsonIgnore: KtReferenceFactory;
|
|
11
9
|
export declare const jsonAnySetter: KtReferenceFactory;
|
|
12
10
|
export declare const jsonAnyGetter: KtReferenceFactory;
|
|
13
|
-
export declare const objectMapper:
|
|
14
|
-
export declare const serializationFeature:
|
|
15
|
-
export declare const deserializationFeature:
|
|
16
|
-
export declare const jacksonObjectMapper:
|
|
17
|
-
export declare const jacksonMapperBuilder: <TBuilder extends SourceBuilder>(springBootVersion?: SpringBootVersion) => KtReference<TBuilder>;
|
|
11
|
+
export declare const objectMapper: KtReferenceFactory;
|
|
12
|
+
export declare const serializationFeature: KtReferenceFactory;
|
|
13
|
+
export declare const deserializationFeature: KtReferenceFactory;
|
|
14
|
+
export declare const jacksonObjectMapper: KtReferenceFactory;
|
|
18
15
|
//# sourceMappingURL=jackson.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jackson.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/jackson.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"jackson.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/jackson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7E,eAAO,MAAM,YAAY,EAAE,kBAA4F,CAAC;AACxH,eAAO,MAAM,YAAY,EAAE,kBAA4F,CAAC;AACxH,eAAO,MAAM,oBAAoB,EAAE,kBAGlC,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,kBAA4F,CAAC;AACxH,eAAO,MAAM,uBAAuB,EAAE,kBAGrC,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAA2F,CAAC;AACtH,eAAO,MAAM,UAAU,EAAE,kBAA0F,CAAC;AACpH,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,oBAAoB,EAAE,kBAGlC,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,kBAGpC,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAC"}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { ktReference } from '../nodes/reference.js';
|
|
2
|
-
/**
|
|
3
|
-
* Resolves a Jackson package name for the targeted Spring Boot version.
|
|
4
|
-
*
|
|
5
|
-
* Jackson 3 (the default in Spring Boot 4) moved every package **except annotations** from
|
|
6
|
-
* `com.fasterxml.jackson.*` to `tools.jackson.*`. Annotations stay on `com.fasterxml.jackson.annotation`.
|
|
7
|
-
*/
|
|
8
|
-
const jacksonPackage = (subPackage, springBootVersion) => `${springBootVersion === 4 ? 'tools.jackson' : 'com.fasterxml.jackson'}.${subPackage}`;
|
|
9
2
|
// com.fasterxml.jackson.annotation
|
|
10
3
|
export const jsonTypeInfo = ktReference.factory('JsonTypeInfo', 'com.fasterxml.jackson.annotation');
|
|
11
4
|
export const jsonSubTypes = ktReference.factory('JsonSubTypes', 'com.fasterxml.jackson.annotation');
|
|
@@ -16,10 +9,9 @@ export const jsonInclude = ktReference.factory('JsonInclude', 'com.fasterxml.jac
|
|
|
16
9
|
export const jsonIgnore = ktReference.factory('JsonIgnore', 'com.fasterxml.jackson.annotation');
|
|
17
10
|
export const jsonAnySetter = ktReference.factory('JsonAnySetter', 'com.fasterxml.jackson.annotation');
|
|
18
11
|
export const jsonAnyGetter = ktReference.factory('JsonAnyGetter', 'com.fasterxml.jackson.annotation');
|
|
19
|
-
// com.fasterxml.jackson.databind
|
|
20
|
-
export const objectMapper =
|
|
21
|
-
export const serializationFeature =
|
|
22
|
-
export const deserializationFeature =
|
|
23
|
-
// com.fasterxml.jackson.module.kotlin
|
|
24
|
-
export const jacksonObjectMapper =
|
|
25
|
-
export const jacksonMapperBuilder = (springBootVersion = 3) => ktReference('jacksonMapperBuilder', jacksonPackage('module.kotlin', springBootVersion));
|
|
12
|
+
// com.fasterxml.jackson.databind
|
|
13
|
+
export const objectMapper = ktReference.factory('ObjectMapper', 'com.fasterxml.jackson.databind');
|
|
14
|
+
export const serializationFeature = ktReference.factory('SerializationFeature', 'com.fasterxml.jackson.databind');
|
|
15
|
+
export const deserializationFeature = ktReference.factory('DeserializationFeature', 'com.fasterxml.jackson.databind');
|
|
16
|
+
// com.fasterxml.jackson.module.kotlin
|
|
17
|
+
export const jacksonObjectMapper = ktReference.factory('jacksonObjectMapper', 'com.fasterxml.jackson.module.kotlin');
|
package/esm/src/config.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { DefaultGenerationProviderConfig, OpenApiGeneratorConfig, StringCasing, StringCasingWithOptions } from '@goast/core';
|
|
2
|
-
/** The Spring Boot major version the Kotlin generators target. */
|
|
3
|
-
export type SpringBootVersion = 3 | 4;
|
|
4
2
|
export type KotlinGeneratorConfig = OpenApiGeneratorConfig & {
|
|
5
3
|
typeNameCasing: StringCasing | StringCasingWithOptions;
|
|
6
4
|
parameterNameCasing: StringCasing | StringCasingWithOptions;
|
|
@@ -14,14 +12,6 @@ export type KotlinGeneratorConfig = OpenApiGeneratorConfig & {
|
|
|
14
12
|
* @default false
|
|
15
13
|
*/
|
|
16
14
|
includeSourceInDocs: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* The targeted Spring Boot major version. Controls Jackson package names, Kotlin generic bounds, and
|
|
19
|
-
* `ResponseEntity` nullability so the generated code compiles against the matching framework generation.
|
|
20
|
-
* - `3`: Spring Boot 3 (Spring Framework 6 / Jackson 2). Produces output identical to previous versions.
|
|
21
|
-
* - `4`: Spring Boot 4 (Spring Framework 7 / Jackson 3 / JSpecify null-safety).
|
|
22
|
-
* @default 3
|
|
23
|
-
*/
|
|
24
|
-
springBootVersion: SpringBootVersion;
|
|
25
15
|
};
|
|
26
16
|
export declare const defaultKotlinGeneratorConfig: DefaultGenerationProviderConfig<KotlinGeneratorConfig>;
|
|
27
17
|
//# sourceMappingURL=config.d.ts.map
|
package/esm/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,YAAY,EACZ,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,YAAY,EACZ,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,GAAG;IAC3D,cAAc,EAAE,YAAY,GAAG,uBAAuB,CAAC;IACvD,mBAAmB,EAAE,YAAY,GAAG,uBAAuB,CAAC;IAC5D,kBAAkB,EAAE,YAAY,GAAG,uBAAuB,CAAC;IAC3D,kBAAkB,EAAE,YAAY,GAAG,uBAAuB,CAAC;IAC3D,mBAAmB,EAAE,YAAY,GAAG,uBAAuB,CAAC;IAC5D,kBAAkB,EAAE,YAAY,GAAG,uBAAuB,CAAC;IAE3D,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,+BAA+B,CAAC,qBAAqB,CAuB/F,CAAC"}
|
package/esm/src/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"okhttp3-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iCAAiC,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,mCAAmC,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAE3G,KAAK,OAAO,GAAG,mCAAmC,CAAC;AACnD,KAAK,MAAM,GAAG,kCAAkC,CAAC;AACjD,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACrE,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,6BAA8B,SAAQ,mBAAmB,CAAC,OAAO,EAAE,MAAM,CACpF,YAAW,sBAAsB;IAC1B,QAAQ,CAAC,GAAG,EAAE,mCAAmC,GAAG,YAAY,CAAC,MAAM,CAAC;IAkB/E,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,oBAAoB,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAIzG,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"okhttp3-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iCAAiC,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,mCAAmC,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAE3G,KAAK,OAAO,GAAG,mCAAmC,CAAC;AACnD,KAAK,MAAM,GAAG,kCAAkC,CAAC;AACjD,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,sBAAsB,CAAC,OAAO,SA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31
|
extends: ctx.refs.apiClient(),
|
|
32
32
|
primaryConstructor: kt.constructor([
|
|
33
|
-
serializerAsParameter
|
|
34
|
-
? kt.parameter('objectMapper', kt.refs.jackson.objectMapper(ctx.config.springBootVersion))
|
|
35
|
-
: null,
|
|
33
|
+
serializerAsParameter ? kt.parameter('objectMapper', kt.refs.jackson.objectMapper()) : null,
|
|
36
34
|
kt.parameter('basePath', kt.refs.string(), { default: 'defaultBasePath' }),
|
|
37
35
|
kt.parameter('client', kt.refs.okhttp3.okHttpClient(), {
|
|
38
36
|
default: 'defaultClient',
|
|
39
37
|
}),
|
|
40
|
-
serializerAsParameter
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
default: kt.call([ctx.refs.serializer(), 'jacksonObjectMapper']),
|
|
44
|
-
}),
|
|
38
|
+
serializerAsParameter ? null : kt.parameter('objectMapper', kt.refs.jackson.objectMapper(), {
|
|
39
|
+
default: kt.call([ctx.refs.serializer(), 'jacksonObjectMapper']),
|
|
40
|
+
}),
|
|
45
41
|
], null, {
|
|
46
42
|
delegateTarget: 'super',
|
|
47
43
|
delegateArguments: ['basePath', 'objectMapper', 'client'],
|
|
@@ -109,31 +105,31 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
109
105
|
return appendValueGroup([
|
|
110
106
|
s `val localVarResponse = ${kt.call([toCasing(endpoint.name + '_WithHttpInfo', ctx.config.functionNameCasing)], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`,
|
|
111
107
|
'',
|
|
112
|
-
s `return when (localVarResponse.responseType) {${s.indent `
|
|
108
|
+
s `return when (localVarResponse.responseType) {${s.indent `
|
|
113
109
|
${ctx.refs.responseType()}.Success -> ${responseSchema === undefined
|
|
114
110
|
? kt.refs.unit()
|
|
115
111
|
: s `(localVarResponse as ${ctx.refs.success(['*'])}).data as ${this.getTypeUsage(ctx, {
|
|
116
112
|
schema: responseSchema,
|
|
117
|
-
})}`}
|
|
118
|
-
${ctx.refs.responseType()}.Informational -> throw ${kt.refs.java.unsupportedOperationException()}("Client does not support Informational responses.")
|
|
119
|
-
${ctx.refs.responseType()}.Redirection -> throw ${kt.refs.java.unsupportedOperationException()}("Client does not support Redirection responses.")
|
|
120
|
-
${ctx.refs.responseType()}.ClientError -> {${s.indent `
|
|
121
|
-
val localVarError = localVarResponse as ${ctx.refs.clientError(['*'])}
|
|
122
|
-
throw ${ctx.refs.clientException()}(${s.indent `
|
|
123
|
-
"Client error : \${localVarError.statusCode} \${localVarError.message.orEmpty()}",
|
|
124
|
-
localVarError.statusCode,
|
|
125
|
-
localVarResponse`}
|
|
126
|
-
)`}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
${ctx.refs.responseType()}.ServerError -> {${s.indent `
|
|
130
|
-
val localVarError = localVarResponse as ${ctx.refs.serverError(['*'])}
|
|
131
|
-
throw ${ctx.refs.serverException()}(${s.indent `
|
|
132
|
-
"Server error : \${localVarError.statusCode} \${localVarError.message.orEmpty()}",
|
|
133
|
-
localVarError.statusCode,
|
|
134
|
-
localVarResponse`}
|
|
135
|
-
)`}
|
|
136
|
-
}`}
|
|
113
|
+
})}`}
|
|
114
|
+
${ctx.refs.responseType()}.Informational -> throw ${kt.refs.java.unsupportedOperationException()}("Client does not support Informational responses.")
|
|
115
|
+
${ctx.refs.responseType()}.Redirection -> throw ${kt.refs.java.unsupportedOperationException()}("Client does not support Redirection responses.")
|
|
116
|
+
${ctx.refs.responseType()}.ClientError -> {${s.indent `
|
|
117
|
+
val localVarError = localVarResponse as ${ctx.refs.clientError(['*'])}
|
|
118
|
+
throw ${ctx.refs.clientException()}(${s.indent `
|
|
119
|
+
"Client error : \${localVarError.statusCode} \${localVarError.message.orEmpty()}",
|
|
120
|
+
localVarError.statusCode,
|
|
121
|
+
localVarResponse`}
|
|
122
|
+
)`}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
${ctx.refs.responseType()}.ServerError -> {${s.indent `
|
|
126
|
+
val localVarError = localVarResponse as ${ctx.refs.serverError(['*'])}
|
|
127
|
+
throw ${ctx.refs.serverException()}(${s.indent `
|
|
128
|
+
"Server error : \${localVarError.statusCode} \${localVarError.message.orEmpty()}",
|
|
129
|
+
localVarError.statusCode,
|
|
130
|
+
localVarResponse`}
|
|
131
|
+
)`}
|
|
132
|
+
}`}
|
|
137
133
|
}`,
|
|
138
134
|
], '\n');
|
|
139
135
|
}
|
|
@@ -212,16 +208,16 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
212
208
|
result.values.push(`val localVariableBody = ${bodyParamName}`);
|
|
213
209
|
}
|
|
214
210
|
}
|
|
215
|
-
result.values.push(s `val localVariableQuery: ${ctx.refs.multiValueMap()} = ${kt.call([kt.refs.mutableMapOf([kt.refs.string(), kt.refs.list([kt.refs.string()])])], [])}${queryParameters.length === 0 ? '' : s.indent `
|
|
216
|
-
.apply {${s.indent `
|
|
211
|
+
result.values.push(s `val localVariableQuery: ${ctx.refs.multiValueMap()} = ${kt.call([kt.refs.mutableMapOf([kt.refs.string(), kt.refs.list([kt.refs.string()])])], [])}${queryParameters.length === 0 ? '' : s.indent `
|
|
212
|
+
.apply {${s.indent `
|
|
217
213
|
${appendValueGroup(queryParameters.map((param) => {
|
|
218
214
|
const paramName = toCasing(param.name, ctx.config.parameterNameCasing);
|
|
219
215
|
const toString = this.getParameterToString(ctx, { endpoint, parameter: param });
|
|
220
216
|
const put = s `put(${kt.string(param.name)}, listOf(${paramName}${toString}))`;
|
|
221
|
-
return param.required ? put : s `if (${paramName} != null) {${s.indent `
|
|
222
|
-
${put}`}
|
|
217
|
+
return param.required ? put : s `if (${paramName} != null) {${s.indent `
|
|
218
|
+
${put}`}
|
|
223
219
|
}`;
|
|
224
|
-
}), '\n')}`}
|
|
220
|
+
}), '\n')}`}
|
|
225
221
|
}`}`);
|
|
226
222
|
result.values.push('val localVariableHeaders: MutableMap<String, String> = mutableMapOf()');
|
|
227
223
|
if (((_b = endpoint.requestBody) === null || _b === void 0 ? void 0 : _b.content[0]) !== undefined) {
|
|
@@ -230,8 +226,8 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
230
226
|
for (const header of headerParameters) {
|
|
231
227
|
const paramName = toCasing(header.name, ctx.config.parameterNameCasing);
|
|
232
228
|
const toString = this.getParameterToString(ctx, { endpoint, parameter: header });
|
|
233
|
-
result.values.push(s `if (${paramName} != null) {${s.indent `
|
|
234
|
-
localVariableHeaders["${header.name}"] = ${paramName}${toString}`}
|
|
229
|
+
result.values.push(s `if (${paramName} != null) {${s.indent `
|
|
230
|
+
localVariableHeaders["${header.name}"] = ${paramName}${toString}`}
|
|
235
231
|
}`);
|
|
236
232
|
}
|
|
237
233
|
result.values.push(s `return ${kt.call([ctx.refs.requestConfig.infer()], [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"okhttp3-clients-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EAGf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EAGtC,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAEL,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACxC,KAAK,oCAAoC,EACzC,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACzC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG3G,KAAK,KAAK,GAAG,kCAAkC,CAAC;AAChD,KAAK,MAAM,GAAG,mCAAmC,CAAC;AAClD,KAAK,MAAM,GAAG,mCAAmC,CAAC;AAClD,KAAK,aAAa,GAAG,kCAAkC,CAAC;AACxD,KAAK,OAAO,GAAG,oCAAoC,CAAC;AAEpD,qBAAa,6BAA8B,SAAQ,qCAAqC,CACtF,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,CACR;IACC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAsC;gBAEnE,uBAAuB,CAAC,EAAE,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC;cAKhD,uBAAuB,CAAC,GAAG,EAAE,oCAAoC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1G,SAAS,CAAC,UAAU,IAAI,MAAM;IAQ9B,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC;IAQzF,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAI1F,SAAS,CAAC,YAAY,CACpB,OAAO,EAAE,uBAAuB,CAAC,4BAA4B,CAAC,EAC9D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,GACnC,OAAO;IAUV,SAAS,CAAC,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAc9D,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAKlC,uBAAuB;
|
|
1
|
+
{"version":3,"file":"okhttp3-clients-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EAGf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EAGtC,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAEL,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACxC,KAAK,oCAAoC,EACzC,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EACzC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG3G,KAAK,KAAK,GAAG,kCAAkC,CAAC;AAChD,KAAK,MAAM,GAAG,mCAAmC,CAAC;AAClD,KAAK,MAAM,GAAG,mCAAmC,CAAC;AAClD,KAAK,aAAa,GAAG,kCAAkC,CAAC;AACxD,KAAK,OAAO,GAAG,oCAAoC,CAAC;AAEpD,qBAAa,6BAA8B,SAAQ,qCAAqC,CACtF,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,CACR;IACC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAsC;gBAEnE,uBAAuB,CAAC,EAAE,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC;cAKhD,uBAAuB,CAAC,GAAG,EAAE,oCAAoC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1G,SAAS,CAAC,UAAU,IAAI,MAAM;IAQ9B,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC;IAQzF,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAI1F,SAAS,CAAC,YAAY,CACpB,OAAO,EAAE,uBAAuB,CAAC,4BAA4B,CAAC,EAC9D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,GACnC,OAAO;IAUV,SAAS,CAAC,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAc9D,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAKlC,uBAAuB;CA+DtC"}
|
|
@@ -85,41 +85,25 @@ export class KotlinOkHttp3ClientsGenerator extends OpenApiServicesGenerationProv
|
|
|
85
85
|
? 'val baseUrl: String, val objectMapper: ObjectMapper, val client: Factory = defaultClient'
|
|
86
86
|
: 'val baseUrl: String, val client: Factory = defaultClient, val objectMapper: ObjectMapper = Serializer.jacksonObjectMapper');
|
|
87
87
|
}
|
|
88
|
-
if (ctx.config.springBootVersion === 4) {
|
|
89
|
-
// Jackson 3 (Spring Boot 4) moved every package except annotations from
|
|
90
|
-
// `com.fasterxml.jackson.*` to `tools.jackson.*`. Rewrite the imports in the copied assets to match.
|
|
91
|
-
fileContent = fileContent.replace(/\bcom\.fasterxml\.jackson\.(core|databind|module|datatype|dataformat)\b/g, 'tools.jackson.$1');
|
|
92
|
-
}
|
|
93
88
|
writeGeneratedFile(ctx.config, targetPath, fileContent);
|
|
94
89
|
}
|
|
95
90
|
if (ctx.config.serializer === 'static' ||
|
|
96
91
|
typeof ctx.config.serializer === 'object' && ctx.config.serializer.mode === 'static') {
|
|
97
92
|
const filePath = resolve(targetDir, 'Serializer.kt');
|
|
98
93
|
console.log(`Generating Serializer to ${filePath}...`);
|
|
99
|
-
const springBootVersion = ctx.config.springBootVersion;
|
|
100
|
-
const jsonIncludeMember = toCasing(ctx.config.serializerJsonInclude, 'snake');
|
|
101
|
-
const defaultFactory = springBootVersion === 4
|
|
102
|
-
// Jackson 3's ObjectMapper is immutable; configuration moved to the (Kotlin) mapper builder.
|
|
103
|
-
? s `${kt.refs.jackson.jacksonMapperBuilder(springBootVersion)}()${s.indent `
|
|
104
|
-
.findAndAddModules()
|
|
105
|
-
.changeDefaultPropertyInclusion { it.withValueInclusion(${kt.refs.jackson.jsonInclude()}.Include.${jsonIncludeMember}).withContentInclusion(${kt.refs.jackson.jsonInclude()}.Include.${jsonIncludeMember}) }
|
|
106
|
-
.configure(${kt.refs.jackson.serializationFeature(springBootVersion)}.WRITE_DATES_AS_TIMESTAMPS, false)
|
|
107
|
-
.configure(${kt.refs.jackson.deserializationFeature(springBootVersion)}.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
|
108
|
-
.build()`}`
|
|
109
|
-
: s `${kt.refs.jackson.jacksonObjectMapper(springBootVersion)}()${s.indent `
|
|
110
|
-
.findAndRegisterModules()
|
|
111
|
-
.setSerializationInclusion(${kt.refs.jackson.jsonInclude()}.Include.${jsonIncludeMember})
|
|
112
|
-
.configure(${kt.refs.jackson.serializationFeature(springBootVersion)}.WRITE_DATES_AS_TIMESTAMPS, false)
|
|
113
|
-
.configure(${kt.refs.jackson.deserializationFeature(springBootVersion)}.FAIL_ON_UNKNOWN_PROPERTIES, false)`}`;
|
|
114
94
|
const factory = typeof ctx.config.serializer === 'object'
|
|
115
95
|
? ctx.config.serializer.factory
|
|
116
|
-
:
|
|
96
|
+
: s `${kt.refs.jackson.jacksonObjectMapper()}()${s.indent `
|
|
97
|
+
.findAndRegisterModules()
|
|
98
|
+
.setSerializationInclusion(${kt.refs.jackson.jsonInclude()}.Include.${toCasing(ctx.config.serializerJsonInclude, 'snake')})
|
|
99
|
+
.configure(${kt.refs.jackson.serializationFeature()}.WRITE_DATES_AS_TIMESTAMPS, false)
|
|
100
|
+
.configure(${kt.refs.jackson.deserializationFeature()}.FAIL_ON_UNKNOWN_PROPERTIES, false)`}`;
|
|
117
101
|
const builder = new KotlinFileBuilder(ctx.infrastructurePackageName, ctx.config);
|
|
118
102
|
builder.append(kt.object({
|
|
119
103
|
name: 'Serializer',
|
|
120
104
|
members: [
|
|
121
105
|
kt.property('jacksonObjectMapper', {
|
|
122
|
-
type: kt.refs.jackson.objectMapper(
|
|
106
|
+
type: kt.refs.jackson.objectMapper(),
|
|
123
107
|
mutable: false,
|
|
124
108
|
default: kt.call('run', [kt.lambda([], factory)]),
|
|
125
109
|
}),
|