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
Prev Previous commit
Adds csharp generator update to handle models with multilevel parent …
…types, which works for the AdditionalPropertiesObject model, samples updated
  • Loading branch information
spacether committed Mar 18, 2019
commit b57caf66ec91827b6fa6bc75923fe9f0de7b95fc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
Expand Down Expand Up @@ -838,4 +839,28 @@ public Mustache.Compiler processCompiler(Mustache.Compiler compiler) {
// To avoid unexpected behaviors when options are passed programmatically such as { "supportsAsync": "" }
return super.processCompiler(compiler).emptyStringIsFalse(true);
}

/**
* Return the instantiation type of the property, especially for map and array
*
* @param schema property schema
* @return string presentation of the instantiation type of the property
*/
@Override
public String toInstantiationType(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
String inner = getSchemaType(additionalProperties);
if (ModelUtils.isMapSchema(additionalProperties)) {
inner = toInstantiationType(additionalProperties);
}
return instantiationTypes.get("map") + "<String, " + inner + ">";
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
String inner = getSchemaType(arraySchema.getItems());
return instantiationTypes.get("array") + "<" + inner + ">";
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Org.OpenAPITools.Model
/// AdditionalPropertiesObject
/// </summary>
[DataContract]
public partial class AdditionalPropertiesObject : Dictionary<String, Dictionary>, IEquatable<AdditionalPropertiesObject>, IValidatableObject
public partial class AdditionalPropertiesObject : Dictionary<String, Dictionary<String, Object>>, IEquatable<AdditionalPropertiesObject>, IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="AdditionalPropertiesObject" /> class.
Expand Down
11 changes: 11 additions & 0 deletions samples/client/petstore/csharp/OpenAPIClientNet35/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ 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
*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 |
Expand Down Expand Up @@ -136,7 +137,14 @@ Class | Method | HTTP request | Description
<a name="documentation-for-models"></a>
## Documentation for Models

- [Model.AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md)
- [Model.AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md)
- [Model.AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md)
- [Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [Model.AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md)
- [Model.AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md)
- [Model.AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md)
- [Model.AdditionalPropertiesString](docs/AdditionalPropertiesString.md)
- [Model.Animal](docs/Animal.md)
- [Model.ApiResponse](docs/ApiResponse.md)
- [Model.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
Expand Down Expand Up @@ -169,7 +177,10 @@ Class | Method | HTTP request | Description
- [Model.Return](docs/Return.md)
- [Model.SpecialModelName](docs/SpecialModelName.md)
- [Model.Tag](docs/Tag.md)
- [Model.TypeHolderDefault](docs/TypeHolderDefault.md)
- [Model.TypeHolderExample](docs/TypeHolderExample.md)
- [Model.User](docs/User.md)
- [Model.XmlItem](docs/XmlItem.md)


<a name="documentation-for-authorization"></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesAnyType
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesArray
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesBoolean
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**MapProperty** | **Dictionary&lt;string, string&gt;** | | [optional]
**MapOfMapProperty** | **Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt;** | | [optional]
**MapString** | **Dictionary&lt;string, string&gt;** | | [optional]
**MapNumber** | **Dictionary&lt;string, decimal?&gt;** | | [optional]
**MapInteger** | **Dictionary&lt;string, int?&gt;** | | [optional]
**MapBoolean** | **Dictionary&lt;string, bool?&gt;** | | [optional]
**MapArrayInteger** | **Dictionary&lt;string, List&lt;int?&gt;&gt;** | | [optional]
**MapArrayAnytype** | **Dictionary&lt;string, List&lt;Object&gt;&gt;** | | [optional]
**MapMapString** | **Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt;** | | [optional]
**MapMapAnytype** | **Dictionary&lt;string, Dictionary&lt;string, Object&gt;&gt;** | | [optional]
**Anytype1** | [**Object**](.md) | | [optional]
**Anytype2** | [**Object**](.md) | | [optional]
**Anytype3** | [**Object**](.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesInteger
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesNumber
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesObject
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Org.OpenAPITools.Model.AdditionalPropertiesString
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
[**CreateXmlItem**](FakeApi.md#createxmlitem) | **POST** /fake/create_xml_item | creates an XmlItem
[**FakeOuterBooleanSerialize**](FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
[**FakeOuterCompositeSerialize**](FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
[**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
Expand All @@ -18,6 +19,66 @@ Method | HTTP request | Description
[**TestJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data


<a name="createxmlitem"></a>
# **CreateXmlItem**
> void CreateXmlItem (XmlItem xmlItem)

creates an XmlItem

this route creates an XmlItem

### Example
```csharp
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
public class CreateXmlItemExample
{
public void main()
{
var apiInstance = new FakeApi();
var xmlItem = new XmlItem(); // XmlItem | XmlItem Body

try
{
// creates an XmlItem
apiInstance.CreateXmlItem(xmlItem);
}
catch (Exception e)
{
Debug.Print("Exception when calling FakeApi.CreateXmlItem: " + e.Message );
}
}
}
}
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**xmlItem** | [**XmlItem**](XmlItem.md)| XmlItem Body |

### Return type

void (empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

<a name="fakeouterbooleanserialize"></a>
# **FakeOuterBooleanSerialize**
> bool? FakeOuterBooleanSerialize (bool? body = null)
Expand Down Expand Up @@ -161,7 +222,7 @@ namespace Example
public void main()
{
var apiInstance = new FakeApi();
var body = 1.2D; // decimal? | Input number as post body (optional)
var body = 8.14; // decimal? | Input number as post body (optional)

try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Org.OpenAPITools.Model.TypeHolderDefault
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**StringItem** | **string** | | [default to "what"]
**NumberItem** | **decimal?** | |
**IntegerItem** | **int?** | |
**BoolItem** | **bool?** | | [default to true]
**ArrayItem** | **List&lt;int?&gt;** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Org.OpenAPITools.Model.TypeHolderExample
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**StringItem** | **string** | |
**NumberItem** | **decimal?** | |
**IntegerItem** | **int?** | |
**BoolItem** | **bool?** | |
**ArrayItem** | **List&lt;int?&gt;** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

37 changes: 37 additions & 0 deletions samples/client/petstore/csharp/OpenAPIClientNet35/docs/XmlItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Org.OpenAPITools.Model.XmlItem
## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**AttributeString** | **string** | | [optional]
**AttributeNumber** | **decimal?** | | [optional]
**AttributeInteger** | **int?** | | [optional]
**AttributeBoolean** | **bool?** | | [optional]
**WrappedArray** | **List&lt;int?&gt;** | | [optional]
**NameString** | **string** | | [optional]
**NameNumber** | **decimal?** | | [optional]
**NameInteger** | **int?** | | [optional]
**NameBoolean** | **bool?** | | [optional]
**NameArray** | **List&lt;int?&gt;** | | [optional]
**NameWrappedArray** | **List&lt;int?&gt;** | | [optional]
**PrefixString** | **string** | | [optional]
**PrefixNumber** | **decimal?** | | [optional]
**PrefixInteger** | **int?** | | [optional]
**PrefixBoolean** | **bool?** | | [optional]
**PrefixArray** | **List&lt;int?&gt;** | | [optional]
**PrefixWrappedArray** | **List&lt;int?&gt;** | | [optional]
**NamespaceString** | **string** | | [optional]
**NamespaceNumber** | **decimal?** | | [optional]
**NamespaceInteger** | **int?** | | [optional]
**NamespaceBoolean** | **bool?** | | [optional]
**NamespaceArray** | **List&lt;int?&gt;** | | [optional]
**NamespaceWrappedArray** | **List&lt;int?&gt;** | | [optional]
**PrefixNsString** | **string** | | [optional]
**PrefixNsNumber** | **decimal?** | | [optional]
**PrefixNsInteger** | **int?** | | [optional]
**PrefixNsBoolean** | **bool?** | | [optional]
**PrefixNsArray** | **List&lt;int?&gt;** | | [optional]
**PrefixNsWrappedArray** | **List&lt;int?&gt;** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Loading