@goast/kotlin 0.5.9-beta.2 → 0.5.10
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 +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/services/okhttp3-clients/okhttp3-client-generator.js +28 -28
- 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 +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 +15 -13
- package/package.json +1 -1
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +28 -28
- 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 +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 +15 -13
- 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 +59 -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 +61 -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 +613 -0
- package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +188 -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 +1109 -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 +586 -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
|
+
}
|
|
@@ -109,31 +109,31 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
109
109
|
return appendValueGroup([
|
|
110
110
|
s `val localVarResponse = ${kt.call([toCasing(endpoint.name + '_WithHttpInfo', ctx.config.functionNameCasing)], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`,
|
|
111
111
|
'',
|
|
112
|
-
s `return when (localVarResponse.responseType) {${s.indent `
|
|
112
|
+
s `return when (localVarResponse.responseType) {${s.indent `
|
|
113
113
|
${ctx.refs.responseType()}.Success -> ${responseSchema === undefined
|
|
114
114
|
? kt.refs.unit()
|
|
115
115
|
: s `(localVarResponse as ${ctx.refs.success(['*'])}).data as ${this.getTypeUsage(ctx, {
|
|
116
116
|
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
|
-
}`}
|
|
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
|
+
}`}
|
|
137
137
|
}`,
|
|
138
138
|
], '\n');
|
|
139
139
|
}
|
|
@@ -212,16 +212,16 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
212
212
|
result.values.push(`val localVariableBody = ${bodyParamName}`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
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 `
|
|
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 `
|
|
217
217
|
${appendValueGroup(queryParameters.map((param) => {
|
|
218
218
|
const paramName = toCasing(param.name, ctx.config.parameterNameCasing);
|
|
219
219
|
const toString = this.getParameterToString(ctx, { endpoint, parameter: param });
|
|
220
220
|
const put = s `put(${kt.string(param.name)}, listOf(${paramName}${toString}))`;
|
|
221
|
-
return param.required ? put : s `if (${paramName} != null) {${s.indent `
|
|
222
|
-
${put}`}
|
|
221
|
+
return param.required ? put : s `if (${paramName} != null) {${s.indent `
|
|
222
|
+
${put}`}
|
|
223
223
|
}`;
|
|
224
|
-
}), '\n')}`}
|
|
224
|
+
}), '\n')}`}
|
|
225
225
|
}`}`);
|
|
226
226
|
result.values.push('val localVariableHeaders: MutableMap<String, String> = mutableMapOf()');
|
|
227
227
|
if (((_b = endpoint.requestBody) === null || _b === void 0 ? void 0 : _b.content[0]) !== undefined) {
|
|
@@ -230,8 +230,8 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
230
230
|
for (const header of headerParameters) {
|
|
231
231
|
const paramName = toCasing(header.name, ctx.config.parameterNameCasing);
|
|
232
232
|
const toString = this.getParameterToString(ctx, { endpoint, parameter: header });
|
|
233
|
-
result.values.push(s `if (${paramName} != null) {${s.indent `
|
|
234
|
-
localVariableHeaders["${header.name}"] = ${paramName}${toString}`}
|
|
233
|
+
result.values.push(s `if (${paramName} != null) {${s.indent `
|
|
234
|
+
localVariableHeaders["${header.name}"] = ${paramName}${toString}`}
|
|
235
235
|
}`);
|
|
236
236
|
}
|
|
237
237
|
result.values.push(s `return ${kt.call([ctx.refs.requestConfig.infer()], [
|
|
@@ -100,16 +100,16 @@ export class KotlinOkHttp3ClientsGenerator extends OpenApiServicesGenerationProv
|
|
|
100
100
|
const jsonIncludeMember = toCasing(ctx.config.serializerJsonInclude, 'snake');
|
|
101
101
|
const defaultFactory = springBootVersion === 4
|
|
102
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)
|
|
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
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)
|
|
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
113
|
.configure(${kt.refs.jackson.deserializationFeature(springBootVersion)}.FAIL_ON_UNKNOWN_PROPERTIES, false)`}`;
|
|
114
114
|
const factory = typeof ctx.config.serializer === 'object'
|
|
115
115
|
? ctx.config.serializer.factory
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AppendValueGroup, type BasicAppendValue, type MaybePromise, SourceBuilder } from '@goast/core';
|
|
1
|
+
import { type ApiEndpoint, type AppendValueGroup, type BasicAppendValue, type MaybePromise, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { kt } from '../../../ast/index.js';
|
|
3
3
|
import type { KotlinImport } from '../../../common-results.js';
|
|
4
4
|
import { KotlinFileBuilder } from '../../../file-builder.js';
|
|
@@ -17,23 +17,23 @@ export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGe
|
|
|
17
17
|
protected generateApiInterfaceFile(ctx: Context, args: Args.GenerateApiInterfaceFile): KotlinImport;
|
|
18
18
|
protected getApiInterfaceFileContent(ctx: Context, args: Args.GetApiInterfaceFileContent): AppendValueGroup<Builder>;
|
|
19
19
|
protected getApiInterface(ctx: Context, args: Args.GetApiInterface): kt.Interface<Builder>;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
protected getApiInterfaceAnnotations(ctx: Context): kt.Annotation<Builder>[];
|
|
21
|
+
protected getApiInterfaceMembers(ctx: Context): kt.InterfaceMember<Builder>[];
|
|
22
22
|
protected getApiInterfaceEndpointMethod(ctx: Context, args: Args.GetApiInterfaceEndpointMethod): kt.Function<Builder>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
protected getApiInterfaceEndpointMethodAnnnotations(ctx: Context, endpoint: ApiEndpoint): kt.Annotation<Builder>[];
|
|
24
|
+
protected getApiInterfaceEndpointMethodParameter(ctx: Context, endpoint: ApiEndpoint, parameter: ApiParameterWithMultipartInfo): kt.Parameter<Builder>;
|
|
25
|
+
protected getApiInterfaceEndpointMethodBody(ctx: Context, endpoint: ApiEndpoint, parameters: ApiParameterWithMultipartInfo[]): AppendValueGroup<Builder>;
|
|
26
|
+
protected getApiResponseEntityClass(ctx: Context, args: Args.GetApiResponseEntityClass): kt.Class<Builder>;
|
|
27
27
|
protected generateApiControllerFile(ctx: Context, args: Args.GenerateApiControllerFile): KotlinImport;
|
|
28
28
|
protected getApiControllerFileContent(ctx: Context, args: Args.GetApiControllerFileContent): AppendValueGroup<Builder>;
|
|
29
29
|
protected getApiController(ctx: Context, args: Args.GetApiController): kt.Class<Builder>;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
protected getApiControllerAnnotations(ctx: Context): kt.Annotation<Builder>[];
|
|
31
|
+
protected getApiControllerMembers(ctx: Context): kt.ClassMember<Builder>[];
|
|
32
32
|
protected generateApiDelegateInterfaceFile(ctx: Context, args: Args.GenerateApiDelegateInterfaceFile): KotlinImport;
|
|
33
33
|
protected getApiDelegateInterfaceFileContent(ctx: Context, args: Args.GetApiDelegateInterfaceFileContent): AppendValueGroup<Builder>;
|
|
34
34
|
protected getApiDelegateInterface(ctx: Context, args: Args.GetApiDelegateInterface): kt.Interface<Builder>;
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
protected getApiDelegateInterfaceAnnotations(ctx: Context): kt.Annotation<Builder>[];
|
|
36
|
+
protected getApiDelegateInterfaceMembers(ctx: Context): kt.InterfaceMember<Builder>[];
|
|
37
37
|
protected getApiDelegateInterfaceEndpointMethod(ctx: Context, args: Args.GetApiDelegateInterfaceEndpointMethod): kt.Function<Builder>;
|
|
38
38
|
protected getParameterType(ctx: Context, args: Args.GetParameterType): kt.Type<Builder>;
|
|
39
39
|
protected getResponseType(ctx: Context, args: Args.GetResponseType): kt.Type<Builder>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE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,EAAE,IAAI,CAAC,gBAAgB,GAC1B,6BAA6B,EAAE;IA2DlC,OAAO,CAAC,kBAAkB;CAkB3B;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQ1D"}
|
|
@@ -4,6 +4,7 @@ import { kt } from '../../../ast/index.js';
|
|
|
4
4
|
import { KotlinFileBuilder } from '../../../file-builder.js';
|
|
5
5
|
import { getSourceDocLine, modifyString } from '../../../utils.js';
|
|
6
6
|
import { KotlinFileGenerator } from '../../file-generator.js';
|
|
7
|
+
const strictResponseCustomProperty = 'strict-response';
|
|
7
8
|
export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator {
|
|
8
9
|
generate(ctx) {
|
|
9
10
|
const packageName = this.getPackageName(ctx, {});
|
|
@@ -81,9 +82,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
81
82
|
ctx.service.endpoints.forEach((endpoint) => {
|
|
82
83
|
members.push(this.getApiInterfaceEndpointMethod(ctx, { endpoint }));
|
|
83
84
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
members.push(...ctx.service.endpoints
|
|
86
|
+
.filter((endpoint) => { var _a; return (_a = endpoint.custom[strictResponseCustomProperty]) !== null && _a !== void 0 ? _a : ctx.config.strictResponseEntities; })
|
|
87
|
+
.map((endpoint) => this.getApiResponseEntityClass(ctx, { endpoint })));
|
|
87
88
|
return members;
|
|
88
89
|
}
|
|
89
90
|
getApiInterfaceEndpointMethod(ctx, args) {
|
|
@@ -256,13 +257,13 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
});
|
|
259
|
-
body.values.push(s `try {${s.indent `
|
|
260
|
+
body.values.push(s `try {${s.indent `
|
|
260
261
|
return ${kt.call([
|
|
261
262
|
kt.call(kt.reference('getDelegate'), []),
|
|
262
263
|
toCasing(endpoint.name, ctx.config.functionNameCasing),
|
|
263
|
-
], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`}
|
|
264
|
-
} catch (e: ${kt.refs.throwable()}) {${s.indent `
|
|
265
|
-
return getExceptionHandler()?.handleApiException(e) ?: throw e`}
|
|
264
|
+
], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`}
|
|
265
|
+
} catch (e: ${kt.refs.throwable()}) {${s.indent `
|
|
266
|
+
return getExceptionHandler()?.handleApiException(e) ?: throw e`}
|
|
266
267
|
}`);
|
|
267
268
|
return body;
|
|
268
269
|
}
|
|
@@ -324,11 +325,11 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
324
325
|
hasResponseBody ? kt.argument('body') : kt.toNode(null),
|
|
325
326
|
kt.toNode(code),
|
|
326
327
|
contentType
|
|
327
|
-
? s `${kt.refs.spring.linkedMultiValueMap([kt.refs.string(), kt.refs.string()])}().also {
|
|
328
|
-
if (headers != null) {
|
|
329
|
-
it.putAll(headers)
|
|
330
|
-
}
|
|
331
|
-
it.addIfAbsent("Content-Type", ${kt.string(contentType)})
|
|
328
|
+
? s `${kt.refs.spring.linkedMultiValueMap([kt.refs.string(), kt.refs.string()])}().also {
|
|
329
|
+
if (headers != null) {
|
|
330
|
+
it.putAll(headers)
|
|
331
|
+
}
|
|
332
|
+
it.addIfAbsent("Content-Type", ${kt.string(contentType)})
|
|
332
333
|
}`
|
|
333
334
|
: kt.argument('headers'),
|
|
334
335
|
]),
|
|
@@ -467,6 +468,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
467
468
|
return members;
|
|
468
469
|
}
|
|
469
470
|
getApiDelegateInterfaceEndpointMethod(ctx, args) {
|
|
471
|
+
var _a;
|
|
470
472
|
const { endpoint } = args;
|
|
471
473
|
const parameters = this.getAllParameters(ctx, { endpoint });
|
|
472
474
|
const fn = kt.function(toCasing(endpoint.name, ctx.config.functionNameCasing), {
|
|
@@ -476,7 +478,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
476
478
|
return kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }));
|
|
477
479
|
}),
|
|
478
480
|
});
|
|
479
|
-
if (ctx.config.strictResponseEntities) {
|
|
481
|
+
if ((_a = endpoint.custom[strictResponseCustomProperty]) !== null && _a !== void 0 ? _a : ctx.config.strictResponseEntities) {
|
|
480
482
|
const responseEntity = kt.reference.genericFactory(this.getApiResponseEntityName(ctx, { endpoint }), `${this.getPackageName(ctx, {})}.${this.getApiInterfaceName(ctx, {})}`);
|
|
481
483
|
fn.returnType = responseEntity(['*']);
|
|
482
484
|
fn.body = appendValueGroup([
|