@goast/kotlin 0.5.1-beta.1 → 0.5.2
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 -253
- 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 +1 -0
- 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 +1 -0
- 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 +20 -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 +41 -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 +132 -0
- package/src/src/generators/models/index.ts +4 -0
- package/src/src/generators/models/model-generator.ts +703 -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 +88 -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 +597 -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 +93 -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 +1084 -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 +101 -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 +571 -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 +39 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAOrB,KAAK,YAAY,EAKjB,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,+BAA+B,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE3F,KAAK,OAAO,GAAG,2BAA2B,CAAC;AAC3C,KAAK,MAAM,GAAG,0BAA0B,CAAC;AACzC,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACnE,QA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AC,GAAG,IAAI;IAkBhC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,GAAG,MAAM;IASzE,SAAS,CAAC,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,6BAA6B,GAAG,OAAO;IAiDxG,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAAG,MAAM;IAIzF,SAAS,CAAC,mBAAmB,CAC3B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,mBAAmB,GAC7B,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG;QAAE,aAAa,EAAE,WAAW,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAA;KAAE,CAAC,EAAE;IAM5F,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,EAAE;IA4B9F,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,GAAG,iBAAiB,EAAE;IAUvF,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,GAAG,SAAS;IAqB9E,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,OAAO;CASrE"}
|
|
@@ -117,6 +117,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
|
|
|
117
117
|
const nonNullSchema = schema.oneOf.find((x) => x.kind !== 'null');
|
|
118
118
|
if (nonNullSchema) {
|
|
119
119
|
schema = nonNullSchema;
|
|
120
|
+
nullable !== null && nullable !== void 0 ? nullable : (nullable = true);
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
const generatedType = this.getGeneratedType(ctx, { schema, nullable });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/kotlin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marc Schmidt (MaSch0212)",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"tslib": "^2.6.2",
|
|
27
27
|
"http-status-codes": "^2.3.0",
|
|
28
|
-
"@goast/core": "0.5.0
|
|
28
|
+
"@goast/core": "0.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAOrB,KAAK,YAAY,EAKjB,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,+BAA+B,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE3F,KAAK,OAAO,GAAG,2BAA2B,CAAC;AAC3C,KAAK,MAAM,GAAG,0BAA0B,CAAC;AACzC,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,oBAAoB,CAAC,O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ACpC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAkBhC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,GAAG,MAAM;IASzE,SAAS,CAAC,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,6BAA6B,GAAG,OAAO;IAiDxG,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAAG,MAAM;IAIzF,SAAS,CAAC,mBAAmB,CAC3B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,mBAAmB,GAC7B,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG;QAAE,aAAa,EAAE,WAAW,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAA;KAAE,CAAC,EAAE;IAM5F,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,EAAE;IA4B9F,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,GAAG,iBAAiB,EAAE;IAUvF,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,GAAG,SAAS;IAqB9E,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,OAAO;CASrE"}
|
|
@@ -120,6 +120,7 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
120
120
|
const nonNullSchema = schema.oneOf.find((x) => x.kind !== 'null');
|
|
121
121
|
if (nonNullSchema) {
|
|
122
122
|
schema = nonNullSchema;
|
|
123
|
+
nullable !== null && nullable !== void 0 ? nullable : (nullable = true);
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
const generatedType = this.getGeneratedType(ctx, { schema, nullable });
|
package/src/mod.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './src/ast/index.js';
|
|
2
|
+
export * from './src/common-results.js';
|
|
3
|
+
export * from './src/config.js';
|
|
4
|
+
export * from './src/file-builder.js';
|
|
5
|
+
export * from './src/generators/index.js';
|
|
6
|
+
export * from './src/import-collection.js';
|
|
7
|
+
export * from './src/types.js';
|
|
8
|
+
export * from './src/utils.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AssetManager } from '@goast/core';
|
|
2
|
+
import { pathToFileURL, URL } from 'node:url';
|
|
3
|
+
|
|
4
|
+
declare const __filename: string | undefined;
|
|
5
|
+
const scriptUrl = typeof __filename === 'undefined' ? import.meta.url : pathToFileURL(__filename);
|
|
6
|
+
|
|
7
|
+
const manager = new AssetManager(new URL('../assets/', scriptUrl));
|
|
8
|
+
export const getAssetFileContent = manager.getAssetFileContent.bind(manager);
|
|
9
|
+
export const copyAssetFile = manager.copyAssetFile.bind(manager);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export { type KtAccessModifier as AccessModifier } from './common.js';
|
|
2
|
+
export { KtNode as Node } from './node.js';
|
|
3
|
+
export {
|
|
4
|
+
KtAnnotation as Annotation,
|
|
5
|
+
ktAnnotation as annotation,
|
|
6
|
+
type KtAnnotationTarget as AnnotationTarget,
|
|
7
|
+
} from './nodes/annotation.js';
|
|
8
|
+
export { KtArgument as Argument, ktArgument as argument } from './nodes/argument.js';
|
|
9
|
+
export { KtCall as Call, ktCall as call } from './nodes/call.js';
|
|
10
|
+
export {
|
|
11
|
+
KtClass as Class,
|
|
12
|
+
ktClass as class,
|
|
13
|
+
type KtClassKind as ClassKind,
|
|
14
|
+
type KtClassMember as ClassMember,
|
|
15
|
+
} from './nodes/class.js';
|
|
16
|
+
export {
|
|
17
|
+
KtCollectionLiteral as CollectionLiteral,
|
|
18
|
+
ktCollectionLiteral as collectionLiteral,
|
|
19
|
+
} from './nodes/collection-literal.js';
|
|
20
|
+
export {
|
|
21
|
+
KtConstructor as Constructor,
|
|
22
|
+
ktConstructor as constructor,
|
|
23
|
+
type KtDelegateTarget as DelegateTarget,
|
|
24
|
+
} from './nodes/constructor.js';
|
|
25
|
+
export { KtDocTag as DocTag, ktDocTag as docTag } from './nodes/doc-tag.js';
|
|
26
|
+
export { KtDoc as Doc, ktDoc as doc } from './nodes/doc.js';
|
|
27
|
+
export {
|
|
28
|
+
KtEnumValue as EnumValue,
|
|
29
|
+
ktEnumValue as enumValue,
|
|
30
|
+
type KtEnumValueMember as EnumValueMember,
|
|
31
|
+
} from './nodes/enum-value.js';
|
|
32
|
+
export { KtEnum as Enum, ktEnum as enum, type KtEnumMember as EnumMember } from './nodes/enum.js';
|
|
33
|
+
export { KtFunction as Function, ktFunction as function } from './nodes/function.js';
|
|
34
|
+
export {
|
|
35
|
+
KtGenericParameter as GenericParameter,
|
|
36
|
+
ktGenericParameter as genericParameter,
|
|
37
|
+
} from './nodes/generic-parameter.js';
|
|
38
|
+
export { KtInitBlock as InitBlock, ktInitBlock as initBlock } from './nodes/init-block.js';
|
|
39
|
+
export {
|
|
40
|
+
KtInterface as Interface,
|
|
41
|
+
ktInterface as interface,
|
|
42
|
+
type KtInterfaceMember as InterfaceMember,
|
|
43
|
+
} from './nodes/interface.js';
|
|
44
|
+
export { KtLambdaType as LambdaType, ktLambdaType as lambdaType } from './nodes/lambda-type.js';
|
|
45
|
+
export { KtLambda as Lambda, ktLambda as lambda } from './nodes/lambda.js';
|
|
46
|
+
export { KtObject as Object, ktObject as object, type KtObjectMember as ObjectMember } from './nodes/object.js';
|
|
47
|
+
export { KtParameter as Parameter, ktParameter as parameter } from './nodes/parameter.js';
|
|
48
|
+
export {
|
|
49
|
+
KtProperty as Property,
|
|
50
|
+
ktProperty as property,
|
|
51
|
+
KtPropertyAccessor as PropertyAccessor,
|
|
52
|
+
KtPropertyGetter as PropertyGetter,
|
|
53
|
+
KtPropertySetter as PropertySetter,
|
|
54
|
+
} from './nodes/property.js';
|
|
55
|
+
export {
|
|
56
|
+
type KtGenericReferenceFactory as GenericReferenceFactory,
|
|
57
|
+
KtReference as Reference,
|
|
58
|
+
ktReference as reference,
|
|
59
|
+
type KtReferenceFactory as ReferenceFactory,
|
|
60
|
+
} from './nodes/reference.js';
|
|
61
|
+
export { KtString as String, ktString as string } from './nodes/string.js';
|
|
62
|
+
export { type KtType as Type, type KtValue as Value } from './nodes/types.js';
|
|
63
|
+
export * as refs from './references/index.js';
|
|
64
|
+
export { getKotlinBuilderOptions as getBuilderOptions } from './utils/get-kotlin-builder-options.js';
|
|
65
|
+
export { toKtNode as toNode } from './utils/to-kt-node.js';
|
|
66
|
+
export { writeKtNode as writeNode, writeKtNodes as writeNodes } from './utils/write-kt-node.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type KtAccessModifier = 'public' | 'protected' | 'internal' | 'private';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as kt from './_index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AstNode, type AstNodeOptions, type SourceBuilder } from '@goast/core';
|
|
2
|
+
|
|
3
|
+
export abstract class KtNode<TBuilder extends SourceBuilder, TInjects extends string = never> extends AstNode<
|
|
4
|
+
TBuilder,
|
|
5
|
+
TInjects
|
|
6
|
+
> {
|
|
7
|
+
constructor(options: AstNodeOptions<typeof AstNode<TBuilder, TInjects>>) {
|
|
8
|
+
super(options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type AstNodeOptions, notNullish, type Nullable, type Prettify, type SourceBuilder } from '@goast/core';
|
|
2
|
+
|
|
3
|
+
import { KtNode } from '../node.js';
|
|
4
|
+
import { writeKtAnnotations } from '../utils/write-kt-annotations.js';
|
|
5
|
+
import { writeKtNode } from '../utils/write-kt-node.js';
|
|
6
|
+
import { type KtArgument, ktArgument } from './argument.js';
|
|
7
|
+
import type { KtType, KtValue } from './types.js';
|
|
8
|
+
|
|
9
|
+
type Injects = 'class' | 'target' | 'arguments';
|
|
10
|
+
|
|
11
|
+
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
12
|
+
typeof KtNode<TBuilder, TInjects | Injects>,
|
|
13
|
+
{
|
|
14
|
+
class: KtType<TBuilder>;
|
|
15
|
+
arguments?: Nullable<Nullable<KtArgument<TBuilder> | KtValue<TBuilder>>[]>;
|
|
16
|
+
target?: Nullable<KtAnnotationTarget>;
|
|
17
|
+
}
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export type KtAnnotationTarget =
|
|
21
|
+
| 'file'
|
|
22
|
+
| 'property'
|
|
23
|
+
| 'field'
|
|
24
|
+
| 'get'
|
|
25
|
+
| 'set'
|
|
26
|
+
| 'receiver'
|
|
27
|
+
| 'param'
|
|
28
|
+
| 'setparam'
|
|
29
|
+
| 'delegate';
|
|
30
|
+
|
|
31
|
+
export class KtAnnotation<TBuilder extends SourceBuilder, TInjects extends string = never> extends KtNode<
|
|
32
|
+
TBuilder,
|
|
33
|
+
TInjects | Injects
|
|
34
|
+
> {
|
|
35
|
+
public class: KtType<TBuilder>;
|
|
36
|
+
public arguments: (KtArgument<TBuilder> | KtValue<TBuilder>)[];
|
|
37
|
+
public target: KtAnnotationTarget | null;
|
|
38
|
+
|
|
39
|
+
constructor(options: Options<TBuilder, TInjects>) {
|
|
40
|
+
super(options);
|
|
41
|
+
this.class = options.class;
|
|
42
|
+
this.arguments = options.arguments?.filter(notNullish) ?? [];
|
|
43
|
+
this.target = options.target ?? null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected override onWrite(builder: TBuilder): void {
|
|
47
|
+
builder.append('@');
|
|
48
|
+
|
|
49
|
+
if (this.target) {
|
|
50
|
+
builder.append(this.inject.beforeTarget);
|
|
51
|
+
builder.append(this.target);
|
|
52
|
+
builder.append(this.inject.afterTarget);
|
|
53
|
+
builder.append(':');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
builder.append(this.inject.beforeClass);
|
|
57
|
+
writeKtNode(builder, this.class);
|
|
58
|
+
builder.append(this.inject.afterClass);
|
|
59
|
+
|
|
60
|
+
if (this.arguments.length > 0) {
|
|
61
|
+
builder.append(this.inject.beforeArguments);
|
|
62
|
+
ktArgument.write(builder, this.arguments);
|
|
63
|
+
builder.append(this.inject.afterArguments);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const createAnnotation = <TBuilder extends SourceBuilder>(
|
|
69
|
+
$class: Options<TBuilder>['class'],
|
|
70
|
+
$arguments?: Options<TBuilder>['arguments'],
|
|
71
|
+
options?: Prettify<Omit<Options<TBuilder>, 'class' | 'arguments'>>,
|
|
72
|
+
): KtAnnotation<TBuilder> => new KtAnnotation<TBuilder>({ ...options, class: $class, arguments: $arguments });
|
|
73
|
+
|
|
74
|
+
export const ktAnnotation: typeof createAnnotation & { write: typeof writeKtAnnotations } = Object.assign(
|
|
75
|
+
createAnnotation,
|
|
76
|
+
{
|
|
77
|
+
write: writeKtAnnotations,
|
|
78
|
+
},
|
|
79
|
+
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
|
+
|
|
3
|
+
import { KtNode } from '../node.js';
|
|
4
|
+
import { writeKtArguments } from '../utils/write-kt-arguments.js';
|
|
5
|
+
import { writeKtNode } from '../utils/write-kt-node.js';
|
|
6
|
+
import type { KtValue } from './types.js';
|
|
7
|
+
|
|
8
|
+
type Injects = 'name' | 'value';
|
|
9
|
+
|
|
10
|
+
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
11
|
+
typeof KtNode<TBuilder, TInjects | Injects>,
|
|
12
|
+
{
|
|
13
|
+
name?: Nullable<string>;
|
|
14
|
+
value: KtValue<TBuilder>;
|
|
15
|
+
}
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export class KtArgument<TBuilder extends SourceBuilder, TInjects extends string = never> extends KtNode<
|
|
19
|
+
TBuilder,
|
|
20
|
+
TInjects | Injects
|
|
21
|
+
> {
|
|
22
|
+
public name: string | null;
|
|
23
|
+
public value: KtValue<TBuilder>;
|
|
24
|
+
|
|
25
|
+
constructor(options: Options<TBuilder, TInjects>) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.name = options?.name ?? null;
|
|
28
|
+
this.value = options.value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected override onWrite(builder: TBuilder): void {
|
|
32
|
+
if (this.name) {
|
|
33
|
+
builder.append(this.inject.beforeName);
|
|
34
|
+
builder.append(this.name);
|
|
35
|
+
builder.append(this.inject.afterName);
|
|
36
|
+
builder.append(' = ');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
builder.append(this.inject.beforeValue);
|
|
40
|
+
writeKtNode(builder, this.value);
|
|
41
|
+
builder.append(this.inject.afterValue);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const createArgument = <TBuilder extends SourceBuilder>(
|
|
46
|
+
value: Options<TBuilder>['value'],
|
|
47
|
+
options?: Prettify<Omit<Options<TBuilder>, 'value'>>,
|
|
48
|
+
): KtArgument<TBuilder> => new KtArgument<TBuilder>({ ...options, value });
|
|
49
|
+
|
|
50
|
+
const createNamedArgument = <TBuilder extends SourceBuilder>(
|
|
51
|
+
name: Options<TBuilder>['name'],
|
|
52
|
+
value: Options<TBuilder>['value'],
|
|
53
|
+
options?: Prettify<Omit<Options<TBuilder>, 'value' | 'name'>>,
|
|
54
|
+
): KtArgument<TBuilder> => new KtArgument<TBuilder>({ ...options, value, name });
|
|
55
|
+
|
|
56
|
+
export const ktArgument: typeof createArgument & {
|
|
57
|
+
named: typeof createNamedArgument;
|
|
58
|
+
write: typeof writeKtArguments;
|
|
59
|
+
} = Object.assign(createArgument, {
|
|
60
|
+
named: createNamedArgument,
|
|
61
|
+
write: writeKtArguments,
|
|
62
|
+
});
|