csharp generator update for v1.8 (#39)

* handle intorstr and quantity in csharp

* remove generated public property from quantity

* add comment why mkdir before docker build
This commit is contained in:
Boshi Lian
2017-12-08 21:31:38 +08:00
committed by Brendan Burns
parent 86d53c7c0b
commit a867e60133
3 changed files with 11 additions and 3 deletions

View File

@@ -47,9 +47,15 @@ popd > /dev/null
source "${SCRIPT_ROOT}/client-generator.sh"
source "${SETTING_FILE}"
# this is to ensure sed after docker build has perm to modify files generated
mkdir -p ${OUTPUT_DIR}/Models/
# TODO(brendandburns): Update CLEANUP_DIRS
CLIENT_LANGUAGE=csharp; CLEANUP_DIRS=(docs src target gradle); kubeclient::generator::generate_client "${OUTPUT_DIR}"
# hack for generating empty host url
sed -i '/BaseUri = new System.Uri(\"\");/ d' ${OUTPUT_DIR}/Kubernetes.cs
# remove public prop from Quantity, (autorest cannot generate empty class)
sed -i '/JsonProperty/ d' ${OUTPUT_DIR}/Models/ResourceQuantity.cs
sed -i 's/public string Value/private string Value/' ${OUTPUT_DIR}/Models/ResourceQuantity.cs

View File

@@ -43,8 +43,8 @@
<argument>--debug</argument>
<argument>--verbose</argument>
<argument>--directive={from: "swagger-document", where: "$..*[?(@.consumes[0] === \"*/*\")]", transform: "$.consumes[0] = \"application/json\""}</argument>
<argument>--directive={from: "swagger-document", where: "$.definitions", transform: "$[\"IntOrString\"] = {\"properties\": { \"value\": { \"type\": \"string\" }}}"}</argument>
<argument>--directive={from: "swagger-document", where: "$..*[?(@.format === \"int-or-string\")]", transform: "delete $.type; delete $.format; $[\"$ref\"] = \"#/definitions/IntOrString\""}</argument>
<argument>--directive={from: "swagger-document", where: "$.definitions", transform: "$[\"intstr.IntOrString\"] = {\"properties\": { \"value\": { \"type\": \"string\" }}}"}</argument>
<argument>--directive={from: "swagger-document", where: "$.definitions", transform: "$[\"resource.Quantity\"] = {\"properties\": { \"value\": { \"type\": \"string\" }}}"}</argument>
<argument>--use=@microsoft.azure/autorest.csharp@preview</argument>
</arguments>
</configuration>

View File

@@ -134,6 +134,8 @@ def process_swagger(spec, client_language):
def preserved_primitives_for_language(client_language):
if client_language == "java":
return ["intstr.IntOrString", "resource.Quantity"]
elif client_language == "csharp":
return ["intstr.IntOrString", "resource.Quantity"]
else:
return []