-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[java native][dotnetcore] Implement QueryParameter deepObject style #8563
Merged
wing328
merged 1 commit into
OpenAPITools:master
from
Reinhard-PTV:deepobject-javanative-dotnetcore
Feb 14, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...c/test/java/org/openapitools/codegen/csharpnetcore/CSharpNetCoreClientDeepObjectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | ||
* Copyright 2018 SmartBear Software | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.openapitools.codegen.csharpnetcore; | ||
|
||
import io.swagger.parser.OpenAPIParser; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.parser.core.models.ParseOptions; | ||
import org.openapitools.codegen.ClientOptInput; | ||
import org.openapitools.codegen.CodegenConstants; | ||
import org.openapitools.codegen.DefaultGenerator; | ||
import org.openapitools.codegen.languages.CSharpNetCoreClientCodegen; | ||
import org.openapitools.codegen.languages.JavaClientCodegen; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.openapitools.codegen.TestUtils.assertFileContains; | ||
|
||
public class CSharpNetCoreClientDeepObjectTest { | ||
|
||
@Test | ||
public void deepObject() throws IOException { | ||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); | ||
output.deleteOnExit(); | ||
String outputPath = output.getAbsolutePath().replace('\\', '/'); | ||
|
||
OpenAPI openAPI = new OpenAPIParser() | ||
.readLocation("src/test/resources/3_0/deepobject.yaml", null, new ParseOptions()).getOpenAPI(); | ||
|
||
CSharpNetCoreClientCodegen codegen = new CSharpNetCoreClientCodegen(); | ||
codegen.setOutputDir(output.getAbsolutePath()); | ||
|
||
ClientOptInput input = new ClientOptInput(); | ||
input.openAPI(openAPI); | ||
input.config(codegen); | ||
|
||
DefaultGenerator generator = new DefaultGenerator(); | ||
|
||
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); | ||
generator.opts(input).generate(); | ||
assertFileContains(Paths.get(outputPath + "/src/Org.OpenAPITools/Api/DefaultApi.cs"), | ||
"options[a]", "options[b]"); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...enapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientDeepObjectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | ||
* Copyright 2018 SmartBear Software | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove this line in one of my upcoming PRs |
||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.openapitools.codegen.java; | ||
|
||
import io.swagger.parser.OpenAPIParser; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.parser.core.models.ParseOptions; | ||
import org.openapitools.codegen.*; | ||
import org.openapitools.codegen.languages.JavaClientCodegen; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import static org.openapitools.codegen.TestUtils.assertFileContains; | ||
|
||
public class JavaClientDeepObjectTest { | ||
|
||
@Test | ||
public void deepObject() throws IOException { | ||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); | ||
output.deleteOnExit(); | ||
String outputPath = output.getAbsolutePath().replace('\\', '/'); | ||
|
||
OpenAPI openAPI = new OpenAPIParser() | ||
.readLocation("src/test/resources/3_0/deepobject.yaml", null, new ParseOptions()).getOpenAPI(); | ||
|
||
JavaClientCodegen codegen = new JavaClientCodegen(); | ||
codegen.setLibrary("native"); | ||
codegen.setOutputDir(output.getAbsolutePath()); | ||
|
||
ClientOptInput input = new ClientOptInput(); | ||
input.openAPI(openAPI); | ||
input.config(codegen); | ||
|
||
DefaultGenerator generator = new DefaultGenerator(); | ||
|
||
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); | ||
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); | ||
generator.opts(input).generate(); | ||
|
||
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/api/DefaultApi.java"), | ||
"options[a]", "options[b]"); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
modules/openapi-generator/src/test/resources/3_0/deepobject.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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 | ||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove this line in one of my upcoming PRs
Ref: https://opensource.stackexchange.com/questions/7300/copyright-notice-in-the-file-header-apache-v2-license