William Cheng fd45b74128
[Java] better default value handling (#14130)
* add test for array default value

* update null return

* minor fixes

* move default value tests to echo api spec

* add new files

* remove unused files

* fix enum array default, add tests

* better array init

* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java

Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>

* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java

Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>

* revert the fix

* improve default value handling

* update native samples, add tests

* update samples

* fix tests

* use conditional test for timezone

* add tests to apache http client echo api

* add option to default container to null

* fix map default value

* minor refactoring

* update samples

* fix javadoc

* fix pom.xml

* add tests in java native echo client

* add java apache client echo tests

* fix test

* fix test

---------

Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>
2023-01-30 20:19:00 +08:00

402 lines
9.5 KiB
YAML

openapi: 3.0.3
info:
contact:
email: team@openapitools.org
description: Echo Server API
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
title: Echo Server API
version: 0.1.0
servers:
- url: http://localhost:3000/
paths:
/path/string/{path_string}/integer/{path_integer}:
get:
description: Test path parameter(s)
operationId: "tests/path/string/{path_string}/integer/{path_integer}"
parameters:
- explode: false
in: path
name: path_string
required: true
schema:
type: string
style: simple
- explode: false
in: path
name: path_integer
required: true
schema:
type: integer
style: simple
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test path parameter(s)
tags:
- path
x-accepts: text/plain
/query/integer/boolean/string:
get:
description: Test query parameter(s)
operationId: test/query/integer/boolean/string
parameters:
- explode: true
in: query
name: integer_query
required: false
schema:
type: integer
style: form
- explode: true
in: query
name: boolean_query
required: false
schema:
type: boolean
style: form
- explode: true
in: query
name: string_query
required: false
schema:
type: string
style: form
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/query/style_form/explode_true/array_string:
get:
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/array_string
parameters:
- explode: true
in: query
name: query_object
required: false
schema:
$ref: '#/components/schemas/test_query_style_form_explode_true_array_string_query_object_parameter'
style: form
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/query/style_form/explode_true/object:
get:
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/object
parameters:
- explode: true
in: query
name: query_object
required: false
schema:
$ref: '#/components/schemas/Pet'
style: form
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/query/style_form/explode_true/object/allOf:
get:
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/object/allOf
parameters:
- explode: true
in: query
name: query_object
required: false
schema:
$ref: '#/components/schemas/DataQuery'
style: form
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/query/style_deepObject/explode_true/object:
get:
description: Test query parameter(s)
operationId: test/query/style_deepObject/explode_true/object
parameters:
- explode: true
in: query
name: query_object
required: false
schema:
$ref: '#/components/schemas/Pet'
style: deepObject
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/query/style_deepObject/explode_true/object/allOf:
get:
description: Test query parameter(s)
operationId: test/query/style_deepObject/explode_true/object/allOf
parameters:
- explode: true
in: query
name: query_object
required: false
schema:
$ref: '#/components/schemas/test_query_style_deepObject_explode_true_object_allOf_query_object_parameter'
style: deepObject
responses:
"200":
content:
text/plain:
schema:
type: string
description: Successful operation
summary: Test query parameter(s)
tags:
- query
x-accepts: text/plain
/echo/body/Pet:
post:
description: Test body parameter(s)
operationId: test/echo/body/Pet
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: Successful operation
summary: Test body parameter(s)
tags:
- body
x-content-type: application/json
x-accepts: application/json
components:
requestBodies:
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
schemas:
Category:
example:
name: Dogs
id: 1
properties:
id:
example: 1
format: int64
type: integer
name:
example: Dogs
type: string
type: object
xml:
name: category
Tag:
example:
name: name
id: 0
properties:
id:
format: int64
type: integer
name:
type: string
type: object
xml:
name: tag
Pet:
example:
photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 10
category:
name: Dogs
id: 1
tags:
- name: name
id: 0
- name: name
id: 0
status: available
properties:
id:
example: 10
format: int64
type: integer
name:
example: doggie
type: string
category:
$ref: '#/components/schemas/Category'
photoUrls:
items:
type: string
xml:
name: photoUrl
type: array
xml:
wrapped: true
tags:
items:
$ref: '#/components/schemas/Tag'
type: array
xml:
wrapped: true
status:
description: pet status in the store
enum:
- available
- pending
- sold
type: string
required:
- name
- photoUrls
type: object
xml:
name: pet
DefaultValue:
description: to test the default value of properties
properties:
array_string_enum_default:
default:
- success
- failure
items:
enum:
- success
- failure
- unclassified
type: string
type: array
array_string_default:
default:
- failure
- skipped
items:
type: string
type: array
array_integer_default:
default:
- 1
- 3
items:
type: integer
type: array
array_string:
items:
type: string
type: array
array_string_nullable:
items:
type: string
nullable: true
type: array
string_nullable:
nullable: true
type: string
type: object
Bird:
properties:
size:
type: string
color:
type: string
type: object
Query:
properties:
id:
description: Query
format: int64
type: integer
outcomes:
default:
- SUCCESS
- FAILURE
items:
enum:
- SUCCESS
- FAILURE
- SKIPPED
type: string
type: array
type: object
x-parent: true
DataQuery:
allOf:
- $ref: '#/components/schemas/DataQuery_allOf'
- $ref: '#/components/schemas/Query'
test_query_style_form_explode_true_array_string_query_object_parameter:
properties:
values:
items:
type: string
type: array
type: object
test_query_style_deepObject_explode_true_object_allOf_query_object_parameter:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
DataQuery_allOf:
properties:
suffix:
description: test suffix
type: string
text:
description: Some text containing white spaces
example: Some text
type: string
date:
description: A date
format: date-time
type: string
type: object
example: null