forked from loafle/openapi-generator-original
fix default value, add nullable support (#16265)
This commit is contained in:
parent
350ec2a763
commit
9322c2fc29
3
.github/workflows/samples-kotlin-server.yaml
vendored
3
.github/workflows/samples-kotlin-server.yaml
vendored
@ -3,9 +3,11 @@ name: Samples Kotlin server
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- samples/server/others/kotlin-server/jaxrs-spec/**
|
||||
- 'samples/server/petstore/kotlin*/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/others/kotlin-server/jaxrs-spec/**
|
||||
- 'samples/server/petstore/kotlin*/**'
|
||||
|
||||
env:
|
||||
@ -31,6 +33,7 @@ jobs:
|
||||
- samples/server/petstore/kotlin-server/jaxrs-spec
|
||||
- samples/server/petstore/kotlin-server/jaxrs-spec-mutiny
|
||||
- samples/server/petstore/kotlin-server-modelMutable
|
||||
- samples/server/others/kotlin-server/jaxrs-spec
|
||||
# no build.gradle file
|
||||
#- samples/server/petstore/kotlin-vertx-modelMutable
|
||||
steps:
|
||||
|
@ -0,0 +1,7 @@
|
||||
generatorName: kotlin-server
|
||||
outputDir: samples/server/others/kotlin-server/jaxrs-spec
|
||||
library: jaxrs-spec
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/parameter-test-spec.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-server
|
||||
additionalProperties:
|
||||
useCoroutines: "true"
|
@ -1 +1 @@
|
||||
{{#isCookieParam}}@CookieParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isCookieParam}}
|
||||
{{#isCookieParam}}@CookieParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue({{{.}}}){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isNullable}}{{/isCookieParam}}
|
@ -1 +1 @@
|
||||
{{#isHeaderParam}}@HeaderParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} {{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isHeaderParam}}
|
||||
{{#isHeaderParam}}@HeaderParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationHeaderParams}}{{/useBeanValidation}} {{#defaultValue}} @DefaultValue({{{.}}}){{/defaultValue}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isNullable}}{{/isHeaderParam}}
|
@ -1 +1 @@
|
||||
{{#isPathParam}}@PathParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isPathParam}}
|
||||
{{#isPathParam}}@PathParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isNullable}}{{/isPathParam}}
|
@ -1 +1 @@
|
||||
{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue("{{{.}}}"){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isQueryParam}}
|
||||
{{#isQueryParam}}@QueryParam("{{baseName}}"){{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{^isContainer}}{{#defaultValue}} @DefaultValue({{{.}}}){{/defaultValue}}{{/isContainer}} {{#useSwaggerAnnotations}}{{#description}} @ApiParam("{{.}}"){{/description}}{{/useSwaggerAnnotations}} {{paramName}}: {{{dataType}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^defaultValue}}{{^required}}?{{/required}}{{/defaultValue}}{{/isNullable}}{{/isQueryParam}}
|
@ -0,0 +1,76 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: test parameters
|
||||
version: 1.0.0
|
||||
title: Test parameters
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
|
||||
paths:
|
||||
/test/parameters/{path_default}/{path_nullable}:
|
||||
get:
|
||||
tags:
|
||||
- default
|
||||
summary: Finds Pets by status
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- name: query_default
|
||||
in: query
|
||||
description: query default
|
||||
style: form
|
||||
explode: false
|
||||
deprecated: true
|
||||
schema:
|
||||
type: string
|
||||
default: available
|
||||
- name: header_default
|
||||
in: header
|
||||
description: header default
|
||||
schema:
|
||||
type: string
|
||||
default: available
|
||||
- name: path_default
|
||||
in: path
|
||||
description: path default
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: cookie_default
|
||||
in: cookie
|
||||
description: cookie default
|
||||
schema:
|
||||
type: string
|
||||
default: available
|
||||
- name: query_nullable
|
||||
in: query
|
||||
description: query nullable
|
||||
style: form
|
||||
explode: false
|
||||
deprecated: true
|
||||
schema:
|
||||
type: string
|
||||
nullable: true
|
||||
- name: header_nullable
|
||||
in: header
|
||||
description: header nullable
|
||||
schema:
|
||||
type: string
|
||||
nullable: true
|
||||
- name: path_nullable
|
||||
in: path
|
||||
required: true
|
||||
description: path_nullable
|
||||
schema:
|
||||
type: string
|
||||
- name: cookie_nullable
|
||||
in: cookie
|
||||
description: cookie_nullable
|
||||
schema:
|
||||
nullable: true
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
'400':
|
||||
description: Invalid status value
|
@ -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
|
@ -0,0 +1,5 @@
|
||||
README.md
|
||||
build.gradle
|
||||
gradle.properties
|
||||
settings.gradle
|
||||
src/main/kotlin/org/openapitools/server/apis/DefaultApi.kt
|
@ -0,0 +1 @@
|
||||
7.0.0-SNAPSHOT
|
49
samples/server/others/kotlin-server/jaxrs-spec/README.md
Normal file
49
samples/server/others/kotlin-server/jaxrs-spec/README.md
Normal file
@ -0,0 +1,49 @@
|
||||
# org.openapitools.server - Kotlin Server library for Test parameters
|
||||
|
||||
## Requires
|
||||
|
||||
* Kotlin 1.4.31
|
||||
* Gradle 6.8.2
|
||||
|
||||
## Build
|
||||
|
||||
First, create the gradle wrapper script:
|
||||
|
||||
```
|
||||
gradle wrapper
|
||||
```
|
||||
|
||||
Then, run:
|
||||
|
||||
```
|
||||
./gradlew check assemble
|
||||
```
|
||||
|
||||
This runs all tests and packages the library.
|
||||
|
||||
## Features/Implementation Notes
|
||||
|
||||
* Supports JSON inputs/outputs, File inputs, and Form inputs.
|
||||
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
|
||||
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
|
||||
|
||||
<a id="documentation-for-api-endpoints"></a>
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://localhost*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*DefaultApi* | [**findPetsByStatus**](docs/DefaultApi.md#findpetsbystatus) | **GET** /test/parameters/{path_default}/{path_nullable} | Finds Pets by status
|
||||
|
||||
|
||||
<a id="documentation-for-models"></a>
|
||||
## Documentation for Models
|
||||
|
||||
|
||||
|
||||
<a id="documentation-for-authorization"></a>
|
||||
## Documentation for Authorization
|
||||
|
||||
Endpoints do not require authorization.
|
||||
|
51
samples/server/others/kotlin-server/jaxrs-spec/build.gradle
Normal file
51
samples/server/others/kotlin-server/jaxrs-spec/build.gradle
Normal file
@ -0,0 +1,51 @@
|
||||
group "org.openapitools"
|
||||
version "1.0.0"
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "6.9"
|
||||
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.7.20"
|
||||
ext.swagger_annotations_version = "1.5.3"
|
||||
ext.jakarta_annotations_version = "1.3.5"
|
||||
ext.jakarta_ws_rs_version = "2.1.6"
|
||||
ext.jackson_version = "2.9.9"
|
||||
repositories {
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "application"
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { setUrl("https://repo1.maven.org/maven2") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
|
||||
implementation("ch.qos.logback:logback-classic:1.2.1")
|
||||
implementation("jakarta.ws.rs:jakarta.ws.rs-api:$jakarta_ws_rs_version")
|
||||
implementation("jakarta.annotation:jakarta.annotation-api:$jakarta_annotations_version")
|
||||
implementation("io.swagger:swagger-annotations:$swagger_annotations_version")
|
||||
implementation("com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version")
|
||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
}
|
@ -0,0 +1 @@
|
||||
org.gradle.caching=true
|
@ -0,0 +1 @@
|
||||
rootProject.name = 'kotlin-server'
|
@ -0,0 +1,20 @@
|
||||
package org.openapitools.server.apis;
|
||||
|
||||
|
||||
import javax.ws.rs.*
|
||||
import javax.ws.rs.core.Response
|
||||
|
||||
|
||||
import java.io.InputStream
|
||||
|
||||
|
||||
|
||||
@Path("/")
|
||||
@javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"))
|
||||
class DefaultApi {
|
||||
|
||||
@GET
|
||||
suspend fun findPetsByStatus(@PathParam("path_default") pathDefault: kotlin.String,@PathParam("path_nullable") pathNullable: kotlin.String,@QueryParam("query_default") @DefaultValue("available") queryDefault: kotlin.String,@HeaderParam("header_default") @DefaultValue("available") headerDefault: kotlin.String,@CookieParam("cookie_default") @DefaultValue("available") cookieDefault: kotlin.String,@QueryParam("query_nullable") queryNullable: kotlin.String?,@HeaderParam("header_nullable") headerNullable: kotlin.String?,@CookieParam("cookie_nullable") cookieNullable: kotlin.String?): Response {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user