-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kotlin-server][ktor2] fix isKtor, update samples (#20327)
* fix isKtor, update samples * fi dockerfile * fix dataclass * add new files * fix template * regenerate samples
- Loading branch information
Showing
6 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...es/openapi-generator/src/main/resources/kotlin-server/libraries/ktor2/data_class.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{{#parcelizeModels}} | ||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
{{/parcelizeModels}} | ||
{{#serializableModel}} | ||
import java.io.Serializable | ||
{{/serializableModel}} | ||
/** | ||
* {{{description}}} | ||
{{#vars}} | ||
* @param {{{name}}} {{{description}}} | ||
{{/vars}} | ||
*/ | ||
{{#parcelizeModels}} | ||
@Parcelize | ||
{{/parcelizeModels}} | ||
{{#hasVars}}data {{/hasVars}}class {{classname}}( | ||
{{#requiredVars}} | ||
{{>data_class_req_var}}{{^-last}}, | ||
{{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}}, | ||
{{/hasOptional}}{{/hasRequired}}{{#optionalVars}}{{>data_class_opt_var}}{{^-last}}, | ||
{{/-last}}{{/optionalVars}} | ||
) {{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{^parcelizeModels}}{{#serializableModel}}: Serializable {{/serializableModel}}{{/parcelizeModels}}{{#parcelizeModels}}{{#serializableModel}} : Parcelable, Serializable {{/serializableModel}}{{/parcelizeModels}} | ||
{{#vendorExtensions.x-has-data-class-body}} | ||
{ | ||
{{/vendorExtensions.x-has-data-class-body}} | ||
{{#serializableModel}} | ||
companion object { | ||
private const val serialVersionUID: Long = 123 | ||
} | ||
{{/serializableModel}} | ||
{{#hasEnums}} | ||
{{#vars}} | ||
{{#isEnum}} | ||
/** | ||
* {{{description}}} | ||
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} | ||
*/ | ||
enum class {{{nameInPascalCase}}}(val value: {{{dataType}}}){ | ||
{{#allowableValues}} | ||
{{#enumVars}} | ||
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}} | ||
{{/enumVars}} | ||
{{/allowableValues}} | ||
} | ||
{{/isEnum}} | ||
{{/vars}} | ||
{{/hasEnums}} | ||
{{#vendorExtensions.x-has-data-class-body}} | ||
} | ||
{{/vendorExtensions.x-has-data-class-body}} |
4 changes: 4 additions & 0 deletions
4
...pi-generator/src/main/resources/kotlin-server/libraries/ktor2/data_class_opt_var.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{{#description}} | ||
/* {{{.}}} */ | ||
{{/description}} | ||
{{>modelMutable}} {{{name}}}: {{#isEnum}}{{{classname}}}.{{{nameInPascalCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}} |
5 changes: 5 additions & 0 deletions
5
...pi-generator/src/main/resources/kotlin-server/libraries/ktor2/data_class_req_var.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{#description}} | ||
/* {{{.}}} */ | ||
{{/description}} | ||
{{! Note that required properties may be nullable according to the OpenAPI specification. }} | ||
{{>modelMutable}} {{{name}}}: {{#isEnum}}{{{classname}}}.{{{nameInPascalCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}} |