Add tests to cover base name (deep object) bug (#14142)

* better deepObject test

* add tests to cover baseName (deep object) change
This commit is contained in:
William Cheng 2022-11-30 00:55:03 +08:00 committed by GitHub
parent b8c8f4a032
commit a92afd239f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 131 additions and 49 deletions

View File

@ -59,6 +59,8 @@ public class CSharpNetCoreClientDeepObjectTest {
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
generator.opts(input).generate();
assertFileContains(Paths.get(outputPath + "/src/Org.OpenAPITools/Api/DefaultApi.cs"),
"options[a]", "options[b]","inputOptions[b]");
"options[id]", "options[name]", "options[category]", "options[tags]",
"options[status]", "options[photoUrls]",
"inputOptions[a]", "inputOptions[b]", "inputOptions[c]");
}
}

View File

@ -58,6 +58,9 @@ public class JavaClientDeepObjectTest {
generator.opts(input).generate();
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/api/DefaultApi.java"),
"options[a]", "options[b]", "\"csv\", \"options[c]\"", "inputOptions[a]");
"options[id]", "options[name]", "options[status]",
"\"csv\", \"options[tags]\"",
"\"csv\", \"options[photoUrls]\"",
"inputOptions[a]", "inputOptions[b]", "\"csv\", \"inputOptions[c]\"");
}
}

View File

@ -1,47 +1,124 @@
openapi: 3.0.3
info:
title: deepobject-test
version: 1.0.0
paths:
/test:
get:
operationId: test
parameters:
- name: options
in: query
required: false
style: deepObject
schema:
$ref: '#/components/schemas/Options'
explode: true
- name: inputOptions
in: query
required: false
style: deepObject
schema:
$ref: '#/components/schemas/Options'
explode: true
responses:
'200':
description: OK
content:
text/plain:
schema:
type: string
components:
schemas:
Options:
type: object
properties:
a:
nullable: true
type: string
format: date-time
b:
type: string
nullable: true
format: date-time
c:
type: array
items:
type: string
openapi: 3.0.3
info:
title: deepobject-test
version: 1.0.0
paths:
/test:
get:
operationId: test
parameters:
- name: options
in: query
required: false
style: deepObject
schema:
$ref: '#/components/schemas/Pet'
explode: true
- name: inputOptions
in: query
required: false
style: deepObject
schema:
$ref: '#/components/schemas/Options'
explode: true
responses:
'200':
description: OK
content:
text/plain:
schema:
type: string
post:
operationId: test_post
parameters:
- name: query_object
in: query
required: false
style: form
schema:
$ref: '#/components/schemas/Pet'
explode: true
responses:
'200':
description: OK
content:
text/plain:
schema:
type: string
components:
schemas:
Options:
type: object
properties:
a:
nullable: true
type: string
format: date-time
b:
type: string
nullable: true
format: date-time
c:
type: array
items:
type: string
Category:
type: object
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: Dogs
xml:
name: category
Tag:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: tag
Pet:
required:
- name
- photoUrls
type: object
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
category:
$ref: '#/components/schemas/Category'
photoUrls:
type: array
xml:
wrapped: true
items:
type: string
xml:
name: photoUrl
tags:
type: array
xml:
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: pet