Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add anytype support to java
  • Loading branch information
wing328 committed May 10, 2020
commit 0b84a8bbca47dbbd6b023af3b2dd287b1d83cf7c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import java.time.LocalDate;
import java.time.ZoneId;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -38,6 +35,8 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -82,7 +81,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected String licenseUrl = "http://unlicense.org";
protected String projectFolder = "src/main";
protected String projectTestFolder = "src/test";
protected String sourceFolder = projectFolder + File.separator +"java";
protected String sourceFolder = projectFolder + File.separator + "java";
protected String testFolder = projectTestFolder + "/java";
protected boolean fullJavaUtil;
protected boolean discriminatorCaseSensitive = true; // True if the discriminator value lookup should be case-sensitive.
Expand Down Expand Up @@ -169,6 +168,7 @@ public AbstractJavaCodegen() {
instantiationTypes.put("map", "HashMap");
typeMapping.put("date", "Date");
typeMapping.put("file", "File");
typeMapping.put("AnyType", "Object");

cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
Expand Down Expand Up @@ -389,12 +389,12 @@ public void processOpts() {
this.setFullJavaUtil(Boolean.valueOf(additionalProperties.get(FULL_JAVA_UTIL).toString()));
}
if (additionalProperties.containsKey(DISCRIMINATOR_CASE_SENSITIVE)) {
this.setDiscriminatorCaseSensitive(Boolean.valueOf(additionalProperties.get(DISCRIMINATOR_CASE_SENSITIVE).toString()));
this.setDiscriminatorCaseSensitive(Boolean.valueOf(additionalProperties.get(DISCRIMINATOR_CASE_SENSITIVE).toString()));
} else {
// By default, the discriminator lookup should be case sensitive. There is nothing in the OpenAPI specification
// that indicates the lookup should be case insensitive. However, some implementations perform
// a case-insensitive lookup.
this.setDiscriminatorCaseSensitive(Boolean.TRUE);
this.setDiscriminatorCaseSensitive(Boolean.TRUE);
}
additionalProperties.put(DISCRIMINATOR_CASE_SENSITIVE, this.discriminatorCaseSensitive);

Expand Down Expand Up @@ -843,12 +843,11 @@ public String toDefaultValue(Schema schema) {
} else if (ModelUtils.isStringSchema(schema)) {
if (schema.getDefault() != null) {
String _default;
if (schema.getDefault() instanceof Date){
if (schema.getDefault() instanceof Date) {
Date date = (Date) schema.getDefault();
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return String.format(Locale.ROOT, localDate.toString(), "");
}
else{
} else {
_default = (String) schema.getDefault();
}
if (schema.getEnum() == null) {
Expand Down Expand Up @@ -1113,7 +1112,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
}

// TODO: Setting additionalProperties is not the responsibility of this method. These side-effects should be moved elsewhere to prevent unexpected behaviors.
if(artifactVersion == null) {
if (artifactVersion == null) {
// If no artifactVersion is provided in additional properties, version from API specification is used.
// If none of them is provided then fallbacks to default version
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION) && additionalProperties.get(CodegenConstants.ARTIFACT_VERSION) != null) {
Expand Down Expand Up @@ -1445,7 +1444,7 @@ public void setFullJavaUtil(boolean fullJavaUtil) {

/**
* Set whether discriminator value lookup is case-sensitive or not.
*
*
* @param discriminatorCaseSensitive true if the discriminator value lookup should be case sensitive.
*/
public void setDiscriminatorCaseSensitive(boolean discriminatorCaseSensitive) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.1-SNAPSHOT
5.0.0-SNAPSHOT
53 changes: 33 additions & 20 deletions samples/client/petstore/java/jersey2-experimental/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# petstore-jersey2
# petstore-jersey2-exp

OpenAPI Petstore

Expand Down Expand Up @@ -39,7 +39,7 @@ Add this dependency to your project's POM:
```xml
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>petstore-jersey2</artifactId>
<artifactId>petstore-jersey2-exp</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Expand All @@ -50,7 +50,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:

```groovy
compile "org.openapitools:petstore-jersey2:1.0.0"
compile "org.openapitools:petstore-jersey2-exp:1.0.0"
```

### Others
Expand All @@ -63,7 +63,7 @@ mvn clean package

Then manually install the following JARs:

- `target/petstore-jersey2-1.0.0.jar`
- `target/petstore-jersey2-exp-1.0.0.jar`
- `target/lib/*.jar`

## Getting Started
Expand All @@ -84,9 +84,9 @@ public class AnotherFakeApiExample {
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");

AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient);
Client body = new Client(); // Client | client model
Client client = new Client(); // Client | client model
try {
Client result = apiInstance.call123testSpecialTags(body);
Client result = apiInstance.call123testSpecialTags(client);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AnotherFakeApi#call123testSpecialTags");
Expand All @@ -107,15 +107,17 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**createXmlItem**](docs/FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo |
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**fakeHttpSignatureTest**](docs/FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
*FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema |
*FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
*FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
Expand Down Expand Up @@ -147,20 +149,11 @@ Class | Method | HTTP request | Description

## Documentation for Models

- [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md)
- [AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md)
- [AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md)
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md)
- [AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md)
- [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md)
- [AdditionalPropertiesString](docs/AdditionalPropertiesString.md)
- [Animal](docs/Animal.md)
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [ArrayTest](docs/ArrayTest.md)
- [BigCat](docs/BigCat.md)
- [BigCatAllOf](docs/BigCatAllOf.md)
- [Capitalization](docs/Capitalization.md)
- [Cat](docs/Cat.md)
- [CatAllOf](docs/CatAllOf.md)
Expand All @@ -173,26 +166,36 @@ Class | Method | HTTP request | Description
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
- [Foo](docs/Foo.md)
- [FormatTest](docs/FormatTest.md)
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [HealthCheckResult](docs/HealthCheckResult.md)
- [InlineObject](docs/InlineObject.md)
- [InlineObject1](docs/InlineObject1.md)
- [InlineObject2](docs/InlineObject2.md)
- [InlineObject3](docs/InlineObject3.md)
- [InlineObject4](docs/InlineObject4.md)
- [InlineObject5](docs/InlineObject5.md)
- [InlineResponseDefault](docs/InlineResponseDefault.md)
- [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model200Response](docs/Model200Response.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [ModelReturn](docs/ModelReturn.md)
- [Name](docs/Name.md)
- [NullableClass](docs/NullableClass.md)
- [NumberOnly](docs/NumberOnly.md)
- [Order](docs/Order.md)
- [OuterComposite](docs/OuterComposite.md)
- [OuterEnum](docs/OuterEnum.md)
- [OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
- [OuterEnumInteger](docs/OuterEnumInteger.md)
- [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [Pet](docs/Pet.md)
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [SpecialModelName](docs/SpecialModelName.md)
- [Tag](docs/Tag.md)
- [TypeHolderDefault](docs/TypeHolderDefault.md)
- [TypeHolderExample](docs/TypeHolderExample.md)
- [User](docs/User.md)
- [XmlItem](docs/XmlItem.md)


## Documentation for Authorization
Expand All @@ -212,9 +215,19 @@ Authentication schemes defined for the API:
- **API key parameter name**: api_key_query
- **Location**: URL query string

### bearer_test


- **Type**: HTTP basic authentication

### http_basic_test


- **Type**: HTTP basic authentication

### http_signature_test


- **Type**: HTTP basic authentication

### petstore_auth
Expand Down