Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public void deepObject() throws IOException {
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]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public void deepObject() throws IOException {
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]\"");
}
}
171 changes: 124 additions & 47 deletions modules/openapi-generator/src/test/resources/3_0/deepobject.yaml
Original file line number Diff line number Diff line change
@@ -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