From 67a850215fa22e8fd27d3d2aa112cd191fb9ce11 Mon Sep 17 00:00:00 2001 From: xichen Date: Mon, 10 Aug 2020 11:04:02 +0800 Subject: [PATCH 1/2] SupportDateTimeRfc1123 --- powershell/llcsharp/schema/schema-resolver.ts | 20 +++++++++++++++++-- .../plugin-create-inline-properties.ts | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/powershell/llcsharp/schema/schema-resolver.ts b/powershell/llcsharp/schema/schema-resolver.ts index 04fb661e33..3a667eb239 100644 --- a/powershell/llcsharp/schema/schema-resolver.ts +++ b/powershell/llcsharp/schema/schema-resolver.ts @@ -183,7 +183,7 @@ export class NewSchemaDefinitionResolver { } return this.add(schema, new NewObjectImplementation(schema)); } - case SchemaType.Choice: + case SchemaType.Time: case SchemaType.String: { return new NewString(schema, required); @@ -193,8 +193,12 @@ export class NewSchemaDefinitionResolver { case SchemaType.Uuid: return new NewUuid(schema, required); case SchemaType.DateTime: + if ((schema).format === StringFormat.DateTimeRfc1123) { + return new NewDateTime1123(schema, required); + } return new NewDateTime(schema, required); - + case SchemaType.ByteArray: + return new NewByteArray(schema, required); case SchemaType.Boolean: return new NewBoolean(schema, required); @@ -227,10 +231,22 @@ export class NewSchemaDefinitionResolver { switch ((schema).valueType.type) { case SchemaType.String: return new NewEnumImplementation(schema, required); + case SchemaType.DateTime: + if ((schema).valueType.format === StringFormat.DateTimeRfc1123) { + return new NewDateTime1123(schema, required); + } + return new NewDateTime(schema, required); default: state.error(`Unsupported constant type. Schema '${schema.language.csharp?.name}' is declared with invalid type '${schema.type}'`, message.UnknownJsonType); throw new Error('Unknown Model. Fatal.'); } + case SchemaType.Choice: { + const choiceSchema = schema as ChoiceSchema; + if ((choiceSchema.choiceType).type === SchemaType.DateTime && (choiceSchema.choiceType).format === StringFormat.DateTimeRfc1123) { + return new NewDateTime1123(schema as DateTimeSchema, required); + } + return new NewString(schema, required); + } case SchemaType.SealedChoice: return new NewEnumImplementation(schema, required); case undefined: diff --git a/powershell/plugins/plugin-create-inline-properties.ts b/powershell/plugins/plugin-create-inline-properties.ts index 0e85e2f05d..1b771e4407 100644 --- a/powershell/plugins/plugin-create-inline-properties.ts +++ b/powershell/plugins/plugin-create-inline-properties.ts @@ -340,7 +340,7 @@ function createVirtualParameters(operation: CommandOperation) { virtualParameters.operation.push({ name: parameter.details.default.name, nameOptions: [parameter.details.default.name], - description: parameter.details.default.description, + description: '', //It should be 'parameter.details.default.description'. But in remodeler, it's using schema.description which is always empty required: parameter.details.default.isBodyParameter ? true : parameter.required, schema: parameter.schema, origin: parameter, From 5ddd840c89b1fd9547d48aae5d8320dcc0bf63d9 Mon Sep 17 00:00:00 2001 From: xichen Date: Mon, 10 Aug 2020 13:51:27 +0800 Subject: [PATCH 2/2] fix --- powershell/plugins/plugin-create-inline-properties.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powershell/plugins/plugin-create-inline-properties.ts b/powershell/plugins/plugin-create-inline-properties.ts index 1b771e4407..0e85e2f05d 100644 --- a/powershell/plugins/plugin-create-inline-properties.ts +++ b/powershell/plugins/plugin-create-inline-properties.ts @@ -340,7 +340,7 @@ function createVirtualParameters(operation: CommandOperation) { virtualParameters.operation.push({ name: parameter.details.default.name, nameOptions: [parameter.details.default.name], - description: '', //It should be 'parameter.details.default.description'. But in remodeler, it's using schema.description which is always empty + description: parameter.details.default.description, required: parameter.details.default.isBodyParameter ? true : parameter.required, schema: parameter.schema, origin: parameter,