From de659936cd027e205c5322d698842ee85fcd6f10 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Thu, 27 Jan 2022 23:35:07 +0100 Subject: [PATCH] Generate sample 'ktorm-schema' project with mutable models --- bin/configs/ktorm-schema-modelMutable.yaml | 8 + .../.openapi-generator-ignore | 23 ++ .../.openapi-generator/FILES | 16 ++ .../.openapi-generator/VERSION | 1 + .../petstore/ktorm-modelMutable/README.md | 29 +++ .../petstore/ktorm-modelMutable/build.gradle | 35 +++ .../ktorm-modelMutable/docs/ApiResponse.md | 15 ++ .../ktorm-modelMutable/docs/Category.md | 13 ++ .../petstore/ktorm-modelMutable/docs/Order.md | 21 ++ .../petstore/ktorm-modelMutable/docs/Pet.md | 41 ++++ .../petstore/ktorm-modelMutable/docs/Tag.md | 13 ++ .../petstore/ktorm-modelMutable/docs/User.md | 25 +++ .../ktorm-modelMutable/ktorm_schema.sql | 211 ++++++++++++++++++ .../ktorm-modelMutable/settings.gradle | 1 + .../database/models/ApiResponse.kt | 63 ++++++ .../openapitools/database/models/Category.kt | 59 +++++ .../org/openapitools/database/models/Order.kt | 76 +++++++ .../org/openapitools/database/models/Pet.kt | 105 +++++++++ .../org/openapitools/database/models/Tag.kt | 59 +++++ .../org/openapitools/database/models/User.kt | 83 +++++++ 20 files changed, 897 insertions(+) create mode 100644 bin/configs/ktorm-schema-modelMutable.yaml create mode 100644 samples/schema/petstore/ktorm-modelMutable/.openapi-generator-ignore create mode 100644 samples/schema/petstore/ktorm-modelMutable/.openapi-generator/FILES create mode 100644 samples/schema/petstore/ktorm-modelMutable/.openapi-generator/VERSION create mode 100644 samples/schema/petstore/ktorm-modelMutable/README.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/build.gradle create mode 100644 samples/schema/petstore/ktorm-modelMutable/docs/ApiResponse.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/docs/Category.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/docs/Order.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/docs/Pet.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/docs/Tag.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/docs/User.md create mode 100644 samples/schema/petstore/ktorm-modelMutable/ktorm_schema.sql create mode 100644 samples/schema/petstore/ktorm-modelMutable/settings.gradle create mode 100644 samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/ApiResponse.kt create mode 100644 samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Category.kt create mode 100644 samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Order.kt create mode 100644 samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Pet.kt create mode 100644 samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Tag.kt create mode 100644 samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/User.kt diff --git a/bin/configs/ktorm-schema-modelMutable.yaml b/bin/configs/ktorm-schema-modelMutable.yaml new file mode 100644 index 000000000000..dc63925fbad4 --- /dev/null +++ b/bin/configs/ktorm-schema-modelMutable.yaml @@ -0,0 +1,8 @@ +generatorName: ktorm-schema +outputDir: samples/schema/petstore/ktorm-modelMutable +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/ktorm-schema +additionalProperties: + hideGenerationTimestamp: true + importModelPackageName: org.openapitools.client.models + modelMutable: "true" diff --git a/samples/schema/petstore/ktorm-modelMutable/.openapi-generator-ignore b/samples/schema/petstore/ktorm-modelMutable/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/schema/petstore/ktorm-modelMutable/.openapi-generator/FILES b/samples/schema/petstore/ktorm-modelMutable/.openapi-generator/FILES new file mode 100644 index 000000000000..a0e918f1301c --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/.openapi-generator/FILES @@ -0,0 +1,16 @@ +README.md +build.gradle +docs/ApiResponse.md +docs/Category.md +docs/Order.md +docs/Pet.md +docs/Tag.md +docs/User.md +ktorm_schema.sql +settings.gradle +src/main/kotlin/org/openapitools/database/models/ApiResponse.kt +src/main/kotlin/org/openapitools/database/models/Category.kt +src/main/kotlin/org/openapitools/database/models/Order.kt +src/main/kotlin/org/openapitools/database/models/Pet.kt +src/main/kotlin/org/openapitools/database/models/Tag.kt +src/main/kotlin/org/openapitools/database/models/User.kt diff --git a/samples/schema/petstore/ktorm-modelMutable/.openapi-generator/VERSION b/samples/schema/petstore/ktorm-modelMutable/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/schema/petstore/ktorm-modelMutable/README.md b/samples/schema/petstore/ktorm-modelMutable/README.md new file mode 100644 index 000000000000..252a12e56d7e --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/README.md @@ -0,0 +1,29 @@ +# org.openapitools.database - Kotlin database library for OpenAPI Petstore + +## Requires + + +## Build + +``` +./gradlew check assemble +``` + +This runs all tests and packages the library. + +## Features/Implementation Notes + +* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions. +* Supports Mapper using API model classes. +* Supports SQLite types. + + +## Documentation for Models + + - [org.openapitools.database.models.ApiResponse](docs/ApiResponse.md) + - [org.openapitools.database.models.Category](docs/Category.md) + - [org.openapitools.database.models.Order](docs/Order.md) + - [org.openapitools.database.models.Pet](docs/Pet.md) + - [org.openapitools.database.models.Tag](docs/Tag.md) + - [org.openapitools.database.models.User](docs/User.md) + diff --git a/samples/schema/petstore/ktorm-modelMutable/build.gradle b/samples/schema/petstore/ktorm-modelMutable/build.gradle new file mode 100644 index 000000000000..00bc14285658 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/build.gradle @@ -0,0 +1,35 @@ +group 'org.openapitools' +version '1.0.0' + +wrapper { + gradleVersion = '4.9' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" +} + +buildscript { + ext.kotlin_version = '1.3.72' + ext.ktorm_version = '3.2.0' + + repositories { + maven { url "https://repo1.maven.org/maven2" } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' + +repositories { + maven { url "https://repo1.maven.org/maven2" } +} + +test { + useJUnitPlatform() +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.ktorm:ktorm-core:$ktorm_version" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" +} diff --git a/samples/schema/petstore/ktorm-modelMutable/docs/ApiResponse.md b/samples/schema/petstore/ktorm-modelMutable/docs/ApiResponse.md new file mode 100644 index 000000000000..33b451cae906 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/docs/ApiResponse.md @@ -0,0 +1,15 @@ + +# Table `ApiResponse` +(mapped from: ApiResponse) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +**code** | code | int | | **kotlin.Int** | | [optional] +**type** | type | text | | **kotlin.String** | | [optional] +**message** | message | text | | **kotlin.String** | | [optional] + + + + + diff --git a/samples/schema/petstore/ktorm-modelMutable/docs/Category.md b/samples/schema/petstore/ktorm-modelMutable/docs/Category.md new file mode 100644 index 000000000000..2e83eb88012f --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/docs/Category.md @@ -0,0 +1,13 @@ + +# Table `Category` +(mapped from: Category) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +**id** | id | long PRIMARY KEY AUTOINCREMENT | | **kotlin.Long** | | [optional] +**name** | name | text | | **kotlin.String** | | [optional] + + + + diff --git a/samples/schema/petstore/ktorm-modelMutable/docs/Order.md b/samples/schema/petstore/ktorm-modelMutable/docs/Order.md new file mode 100644 index 000000000000..102962a706fe --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/docs/Order.md @@ -0,0 +1,21 @@ + +# Table `Order` +(mapped from: Order) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +**id** | id | long PRIMARY KEY AUTOINCREMENT | | **kotlin.Long** | | [optional] +**petId** | petId | long | | **kotlin.Long** | | [optional] +**quantity** | quantity | int | | **kotlin.Int** | | [optional] +**shipDate** | shipDate | datetime | | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional] +**status** | status | text | | [**status**](#Status) | Order Status | [optional] +**complete** | complete | boolean | | **kotlin.Boolean** | | [optional] + + + + + + + + diff --git a/samples/schema/petstore/ktorm-modelMutable/docs/Pet.md b/samples/schema/petstore/ktorm-modelMutable/docs/Pet.md new file mode 100644 index 000000000000..646fe4d17231 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/docs/Pet.md @@ -0,0 +1,41 @@ + +# Table `Pet` +(mapped from: Pet) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +**name** | name | text NOT NULL | | **kotlin.String** | | +**photoUrls** | `One-To-Many` | `----` | `----` | **kotlin.Array<kotlin.String>** | | +**id** | id | long PRIMARY KEY AUTOINCREMENT | | **kotlin.Long** | | [optional] +**category** | category | long | | [**Category**](Category.md) | | [optional] [foreignkey] +**tags** | `One-To-Many` | `----` | `----` | [**kotlin.Array<Tag>**](Tag.md) | | [optional] +**status** | status | text | | [**status**](#Status) | pet status in the store | [optional] + + + +# **Table `PetPhotoUrls`** +(mapped from: PetPhotoUrls) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +pet | pet | long | | kotlin.Long | Primary Key | *one* +photoUrls | photoUrls | text | | kotlin.String | Foreign Key | *many* + + + + + +# **Table `PetTag`** +(mapped from: PetTag) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +pet | pet | long | | kotlin.Long | Primary Key | *one* +tag | tag | long | | kotlin.Long | Foreign Key | *many* + + + + diff --git a/samples/schema/petstore/ktorm-modelMutable/docs/Tag.md b/samples/schema/petstore/ktorm-modelMutable/docs/Tag.md new file mode 100644 index 000000000000..51a1da4a1434 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/docs/Tag.md @@ -0,0 +1,13 @@ + +# Table `Tag` +(mapped from: Tag) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +**id** | id | long PRIMARY KEY AUTOINCREMENT | | **kotlin.Long** | | [optional] +**name** | name | text | | **kotlin.String** | | [optional] + + + + diff --git a/samples/schema/petstore/ktorm-modelMutable/docs/User.md b/samples/schema/petstore/ktorm-modelMutable/docs/User.md new file mode 100644 index 000000000000..943792b9657f --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/docs/User.md @@ -0,0 +1,25 @@ + +# Table `User` +(mapped from: User) + +## Properties +Name | Mapping | SQL Type | Default | Type | Description | Notes +---- | ------- | -------- | ------- | ---- | ----------- | ----- +**id** | id | long PRIMARY KEY AUTOINCREMENT | | **kotlin.Long** | | [optional] +**username** | username | text | | **kotlin.String** | | [optional] +**firstName** | firstName | text | | **kotlin.String** | | [optional] +**lastName** | lastName | text | | **kotlin.String** | | [optional] +**email** | email | text | | **kotlin.String** | | [optional] +**password** | password | text | | **kotlin.String** | | [optional] +**phone** | phone | text | | **kotlin.String** | | [optional] +**userStatus** | userStatus | int | | **kotlin.Int** | User Status | [optional] + + + + + + + + + + diff --git a/samples/schema/petstore/ktorm-modelMutable/ktorm_schema.sql b/samples/schema/petstore/ktorm-modelMutable/ktorm_schema.sql new file mode 100644 index 000000000000..0f7fcf7eceec --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/ktorm_schema.sql @@ -0,0 +1,211 @@ + + +-- -------------------------------------------------------------------------- +-- Table structure for table `ApiResponse` generated from model 'apiResponse' +-- Describes the result of uploading an image resource +-- + +CREATE TABLE IF NOT EXISTS `ApiResponse` ( + `code` int, + `type` text, + `message` text +); /*Describes the result of uploading an image resource*/ + + +-- -------------------------------------------------------------------------- +-- Table structure for table `Category` generated from model 'category' +-- A category for a pet +-- + +CREATE TABLE IF NOT EXISTS `Category` ( + `id` long PRIMARY KEY AUTOINCREMENT, + `name` text +); /*A category for a pet*/ + + +-- -------------------------------------------------------------------------- +-- Table structure for table `Order` generated from model 'order' +-- An order for a pets from the pet store +-- + +CREATE TABLE IF NOT EXISTS `Order` ( + `id` long PRIMARY KEY AUTOINCREMENT, + `petId` long, + `quantity` int, + `shipDate` datetime, + `status` text /*Order Status*/, + `complete` boolean +); /*An order for a pets from the pet store*/ + + +-- -------------------------------------------------------------------------- +-- Table structure for table `Pet` generated from model 'pet' +-- A pet for sale in the pet store +-- + +CREATE TABLE IF NOT EXISTS `Pet` ( + `name` text NOT NULL, + `id` long PRIMARY KEY AUTOINCREMENT, + `category` long, + `status` text /*pet status in the store*/ +); /*A pet for sale in the pet store*/ + +-- -------------------------------------------------------------------------- +-- Table structure for table `PetPhotoUrls` generated from model 'PetPhotoUrls' + +CREATE TABLE IF NOT EXISTS `PetPhotoUrls` ( + `pet` long NOT NULL + `photoUrls` text NOT NULL +); + +-- -------------------------------------------------------------------------- +-- Table structure for table `PetTag` generated from model 'PetTag' + +CREATE TABLE IF NOT EXISTS `PetTag` ( + `pet` long NOT NULL + `tag` long NOT NULL +); + + +-- -------------------------------------------------------------------------- +-- Table structure for table `Tag` generated from model 'tag' +-- A tag for a pet +-- + +CREATE TABLE IF NOT EXISTS `Tag` ( + `id` long PRIMARY KEY AUTOINCREMENT, + `name` text +); /*A tag for a pet*/ + + +-- -------------------------------------------------------------------------- +-- Table structure for table `User` generated from model 'user' +-- A User who is purchasing from the pet store +-- + +CREATE TABLE IF NOT EXISTS `User` ( + `id` long PRIMARY KEY AUTOINCREMENT, + `username` text, + `firstName` text, + `lastName` text, + `email` text, + `password` text, + `phone` text, + `userStatus` int /*User Status*/ +); /*A User who is purchasing from the pet store*/ + + +-- +-- OAuth2 framework tables +-- Thanks to https://github.com/dsquier/oauth2-server-php-mysql repo +-- + +-- +-- Table structure for table `oauth_clients` +-- +CREATE TABLE IF NOT EXISTS `oauth_clients` ( + `client_id` VARCHAR(80) NOT NULL, + `client_secret` VARCHAR(80) DEFAULT NULL, + `redirect_uri` VARCHAR(2000) DEFAULT NULL, + `grant_types` VARCHAR(80) DEFAULT NULL, + `scope` VARCHAR(4000) DEFAULT NULL, + `user_id` VARCHAR(80) DEFAULT NULL, + PRIMARY KEY (`client_id`) +); + +-- +-- Table structure for table `oauth_access_tokens` +-- +CREATE TABLE IF NOT EXISTS `oauth_access_tokens` ( + `access_token` VARCHAR(40) NOT NULL, + `client_id` VARCHAR(80) DEFAULT NULL, + `user_id` VARCHAR(80) DEFAULT NULL, + `expires` TIMESTAMP NOT NULL, + `scope` VARCHAR(4000) DEFAULT NULL, + PRIMARY KEY (`access_token`) +); + +-- +-- Table structure for table `oauth_authorization_codes` +-- +CREATE TABLE IF NOT EXISTS `oauth_authorization_codes` ( + `authorization_code` VARCHAR(40) NOT NULL, + `client_id` VARCHAR(80) DEFAULT NULL, + `user_id` VARCHAR(80) DEFAULT NULL, + `redirect_uri` VARCHAR(2000) NOT NULL, + `expires` TIMESTAMP NOT NULL, + `scope` VARCHAR(4000) DEFAULT NULL, + `id_token` VARCHAR(1000) DEFAULT NULL, + PRIMARY KEY (`authorization_code`) +); + +-- +-- Table structure for table `oauth_refresh_tokens` +-- +CREATE TABLE IF NOT EXISTS `oauth_refresh_tokens` ( + `refresh_token` VARCHAR(40) NOT NULL, + `client_id` VARCHAR(80) DEFAULT NULL, + `user_id` VARCHAR(80) DEFAULT NULL, + `expires` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `scope` VARCHAR(4000) DEFAULT NULL, + PRIMARY KEY (`refresh_token`) +); + +-- +-- Table structure for table `oauth_users` +-- +CREATE TABLE IF NOT EXISTS `oauth_users` ( + `username` VARCHAR(80) DEFAULT NULL, + `password` VARCHAR(255) DEFAULT NULL, + `first_name` VARCHAR(80) DEFAULT NULL, + `last_name` VARCHAR(80) DEFAULT NULL, + `email` VARCHAR(2000) DEFAULT NULL, + `email_verified` TINYINT(1) DEFAULT NULL, + `scope` VARCHAR(4000) DEFAULT NULL +); + +-- +-- Table structure for table `oauth_scopes` +-- +CREATE TABLE IF NOT EXISTS `oauth_scopes` ( + `scope` VARCHAR(80) NOT NULL, + `is_default` TINYINT(1) DEFAULT NULL, + PRIMARY KEY (`scope`) +); + +-- +-- Table structure for table `oauth_jwt` +-- +CREATE TABLE IF NOT EXISTS `oauth_jwt` ( + `client_id` VARCHAR(80) NOT NULL, + `subject` VARCHAR(80) DEFAULT NULL, + `public_key` VARCHAR(2000) NOT NULL +); + +-- +-- Table structure for table `oauth_jti` +-- +CREATE TABLE IF NOT EXISTS `oauth_jti` ( + `issuer` VARCHAR(80) NOT NULL, + `subject` VARCHAR(80) DEFAULT NULL, + `audience` VARCHAR(80) DEFAULT NULL, + `expires` TIMESTAMP NOT NULL, + `jti` VARCHAR(2000) NOT NULL +); + +-- +-- Table structure for table `oauth_public_keys` +-- +CREATE TABLE IF NOT EXISTS `oauth_public_keys` ( + `client_id` VARCHAR(80) DEFAULT NULL, + `public_key` VARCHAR(2000) DEFAULT NULL, + `private_key` VARCHAR(2000) DEFAULT NULL, + `encryption_algorithm` VARCHAR(100) DEFAULT 'RS256' +); + +-- +-- Table structure for table `_db_version` +-- +CREATE TABLE IF NOT EXISTS `_db_version` ( + `version` LONG DEFAULT 1 +); diff --git a/samples/schema/petstore/ktorm-modelMutable/settings.gradle b/samples/schema/petstore/ktorm-modelMutable/settings.gradle new file mode 100644 index 000000000000..10cb73142be1 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'ktorm' \ No newline at end of file diff --git a/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/ApiResponse.kt b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/ApiResponse.kt new file mode 100644 index 000000000000..055682fab68f --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/ApiResponse.kt @@ -0,0 +1,63 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.database.models + +import org.ktorm.dsl.* +import org.ktorm.schema.* +import org.ktorm.database.Database +import org.openapitools.client.models.* + + +/** + * Describes the result of uploading an image resource + * @param code + * @param type + * @param message + */ +object ApiResponses : BaseTable("ApiResponse") { + val code = int("code") /* null */ + val type = text("type") /* null */ + val message = text("message") /* null */ + + /** + * Create an entity of type ApiResponse from the model + */ + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = ApiResponse( + code = row[code] /* kotlin.Int? */, + type = row[type] /* kotlin.String? */, + message = row[message] /* kotlin.String? */ + ) + + /** + * Assign all the columns from the entity of type ApiResponse to the DML expression. + * + * Usage: + * + * ```kotlin + * let entity = ApiResponse() + * database.update(ApiResponses, { + * assignFrom(entity) + * }) + * ``` + * @return the builder with the columns for the update or insert. + */ + fun AssignmentsBuilder.assignFrom(entity: ApiResponse) { + this.apply { + set(ApiResponses.code, entity.code) + set(ApiResponses.type, entity.type) + set(ApiResponses.message, entity.message) + } + } + +} + + diff --git a/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Category.kt b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Category.kt new file mode 100644 index 000000000000..efe6d748f38b --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Category.kt @@ -0,0 +1,59 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.database.models + +import org.ktorm.dsl.* +import org.ktorm.schema.* +import org.ktorm.database.Database +import org.openapitools.client.models.* + + +/** + * A category for a pet + * @param id + * @param name + */ +object Categorys : BaseTable("Category") { + val id = long("id") /* null */ + val name = text("name") /* null */ + + /** + * Create an entity of type Category from the model + */ + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = Category( + id = row[id] /* kotlin.Long? */, + name = row[name] /* kotlin.String? */ + ) + + /** + * Assign all the columns from the entity of type Category to the DML expression. + * + * Usage: + * + * ```kotlin + * let entity = Category() + * database.update(Categorys, { + * assignFrom(entity) + * }) + * ``` + * @return the builder with the columns for the update or insert. + */ + fun AssignmentsBuilder.assignFrom(entity: Category) { + this.apply { + set(Categorys.id, entity.id) + set(Categorys.name, entity.name) + } + } + +} + + diff --git a/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Order.kt b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Order.kt new file mode 100644 index 000000000000..40b7b6cc5376 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Order.kt @@ -0,0 +1,76 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.database.models + +import org.ktorm.dsl.* +import org.ktorm.schema.* +import org.ktorm.database.Database +import org.openapitools.client.models.* + + +/** + * An order for a pets from the pet store + * @param id + * @param petId + * @param quantity + * @param shipDate + * @param status Order Status + * @param complete + */ +object Orders : BaseTable("Order") { + val id = long("id") /* null */ + val petId = long("petId") /* null */ + val quantity = int("quantity") /* null */ + val shipDate = datetime("shipDate") /* null */ + val status = text("status").transform({ Order.Status.valueOf(it ?: "placed") }, { it.value }) /* null */ /* Order Status */ + + val complete = boolean("complete") /* null */ + + /** + * Create an entity of type Order from the model + */ + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = Order( + id = row[id] /* kotlin.Long? */, + petId = row[petId] /* kotlin.Long? */, + quantity = row[quantity] /* kotlin.Int? */, + shipDate = row[shipDate] /* java.time.LocalDateTime? */, + status = row[status] /* kotlin.String? */ /* Order Status */, + complete = row[complete] ?: false /* kotlin.Boolean? */ + ) + + /** + * Assign all the columns from the entity of type Order to the DML expression. + * + * Usage: + * + * ```kotlin + * let entity = Order() + * database.update(Orders, { + * assignFrom(entity) + * }) + * ``` + * @return the builder with the columns for the update or insert. + */ + fun AssignmentsBuilder.assignFrom(entity: Order) { + this.apply { + set(Orders.id, entity.id) + set(Orders.petId, entity.petId) + set(Orders.quantity, entity.quantity) + set(Orders.shipDate, entity.shipDate) + set(Orders.status, entity.status) + set(Orders.complete, entity.complete) + } + } + +} + + diff --git a/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Pet.kt b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Pet.kt new file mode 100644 index 000000000000..c95e111c3d41 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Pet.kt @@ -0,0 +1,105 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.database.models + +import org.ktorm.dsl.* +import org.ktorm.schema.* +import org.ktorm.database.Database +import org.openapitools.client.models.* + + +/** + * A pet for sale in the pet store + * @param name + * @param photoUrls + * @param id + * @param category + * @param tags + * @param status pet status in the store + */ +object Pets : BaseTable("Pet") { + val name = text("name") + val id = long("id") /* null */ + val category = long("category") /* null */ + @Deprecated(message = "This property is deprecated.") + val status = text("status").transform({ Pet.Status.valueOf(it ?: "available") }, { it.value }) /* null */ /* pet status in the store */ + + + /** + * Create an entity of type Pet from the model + */ + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = Pet( + name = row[name] ?: "" /* kotlin.String */, + photoUrls = emptyList() /* kotlin.Array */, + id = row[id] /* kotlin.Long? */, + category = Categorys.createEntity(row, withReferences) /* Category? */, + tags = emptyList() /* kotlin.Array? */, + status = row[status] /* kotlin.String? */ /* pet status in the store */ + ) + + /** + * Assign all the columns from the entity of type Pet to the DML expression. + * + * Usage: + * + * ```kotlin + * let entity = Pet() + * database.update(Pets, { + * assignFrom(entity) + * }) + * ``` + * @return the builder with the columns for the update or insert. + */ + fun AssignmentsBuilder.assignFrom(entity: Pet) { + this.apply { + set(Pets.name, entity.name) + set(Pets.id, entity.id) + set(Pets.category, entity.category) + set(Pets.status, entity.status) + } + } + +} + + +object PetPhotoUrls : BaseTable>("PetPhotoUrls") { + val pet = long("pet") + val photoUrls = text("photoUrls") + + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Pair = + Pair(row[pet] ?: 0, row[photoUrls] ?: "") + + fun AssignmentsBuilder.assignFrom(entity: Pair) { + this.apply { + set(PetPhotoUrls.pet, entity.first) + set(PetPhotoUrls.photoUrls, entity.second) + } + } + +} + +object PetTag : BaseTable>("PetTag") { + val pet = long("pet") + val tag = long("tag") + + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Pair = + Pair(row[pet] ?: 0, row[tag] ?: 0) + + fun AssignmentsBuilder.assignFrom(entity: Pair) { + this.apply { + set(PetTag.pet, entity.first) + set(PetTag.tag, entity.second) + } + } + +} + diff --git a/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Tag.kt b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Tag.kt new file mode 100644 index 000000000000..1f6148728986 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/Tag.kt @@ -0,0 +1,59 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.database.models + +import org.ktorm.dsl.* +import org.ktorm.schema.* +import org.ktorm.database.Database +import org.openapitools.client.models.* + + +/** + * A tag for a pet + * @param id + * @param name + */ +object Tags : BaseTable("Tag") { + val id = long("id") /* null */ + val name = text("name") /* null */ + + /** + * Create an entity of type Tag from the model + */ + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = Tag( + id = row[id] /* kotlin.Long? */, + name = row[name] /* kotlin.String? */ + ) + + /** + * Assign all the columns from the entity of type Tag to the DML expression. + * + * Usage: + * + * ```kotlin + * let entity = Tag() + * database.update(Tags, { + * assignFrom(entity) + * }) + * ``` + * @return the builder with the columns for the update or insert. + */ + fun AssignmentsBuilder.assignFrom(entity: Tag) { + this.apply { + set(Tags.id, entity.id) + set(Tags.name, entity.name) + } + } + +} + + diff --git a/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/User.kt b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/User.kt new file mode 100644 index 000000000000..98c31bf1be53 --- /dev/null +++ b/samples/schema/petstore/ktorm-modelMutable/src/main/kotlin/org/openapitools/database/models/User.kt @@ -0,0 +1,83 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.database.models + +import org.ktorm.dsl.* +import org.ktorm.schema.* +import org.ktorm.database.Database +import org.openapitools.client.models.* + + +/** + * A User who is purchasing from the pet store + * @param id + * @param username + * @param firstName + * @param lastName + * @param email + * @param password + * @param phone + * @param userStatus User Status + */ +object Users : BaseTable("User") { + val id = long("id") /* null */ + val username = text("username") /* null */ + val firstName = text("firstName") /* null */ + val lastName = text("lastName") /* null */ + val email = text("email") /* null */ + val password = text("password") /* null */ + val phone = text("phone") /* null */ + val userStatus = int("userStatus") /* null */ /* User Status */ + + /** + * Create an entity of type User from the model + */ + override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = User( + id = row[id] /* kotlin.Long? */, + username = row[username] /* kotlin.String? */, + firstName = row[firstName] /* kotlin.String? */, + lastName = row[lastName] /* kotlin.String? */, + email = row[email] /* kotlin.String? */, + password = row[password] /* kotlin.String? */, + phone = row[phone] /* kotlin.String? */, + userStatus = row[userStatus] /* kotlin.Int? */ /* User Status */ + ) + + /** + * Assign all the columns from the entity of type User to the DML expression. + * + * Usage: + * + * ```kotlin + * let entity = User() + * database.update(Users, { + * assignFrom(entity) + * }) + * ``` + * @return the builder with the columns for the update or insert. + */ + fun AssignmentsBuilder.assignFrom(entity: User) { + this.apply { + set(Users.id, entity.id) + set(Users.username, entity.username) + set(Users.firstName, entity.firstName) + set(Users.lastName, entity.lastName) + set(Users.email, entity.email) + set(Users.password, entity.password) + set(Users.phone, entity.phone) + set(Users.userStatus, entity.userStatus) + } + } + +} + +