From c117d09a481234390dc0a3827fe1bbe9ace044db Mon Sep 17 00:00:00 2001 From: derek Date: Thu, 30 Jul 2020 17:16:16 +0800 Subject: [PATCH 1/6] Fix the issue nested ojbect not supported --- powershell/plugins/plugin-create-inline-properties.ts | 2 +- powershell/utils/schema.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/powershell/plugins/plugin-create-inline-properties.ts b/powershell/plugins/plugin-create-inline-properties.ts index 07ecf13568..061b706cc9 100644 --- a/powershell/plugins/plugin-create-inline-properties.ts +++ b/powershell/plugins/plugin-create-inline-properties.ts @@ -210,7 +210,7 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array, thr property: inlinedProperty.property, private: inlinedProperty.private, nameComponents: components, - nameOptions: getNameOptions(inlinedProperty.property.schema.details.default.name, components), + nameOptions: getNameOptions(inlinedProperty.property.schema.language.default.name, components), accessViaProperty: privateProperty, accessViaMember: inlinedProperty, accessViaSchema: schema, diff --git a/powershell/utils/schema.ts b/powershell/utils/schema.ts index c540ac8772..c4117d84a6 100644 --- a/powershell/utils/schema.ts +++ b/powershell/utils/schema.ts @@ -8,7 +8,7 @@ import { Extensions } from './extensions'; import { DeepPartial, } from '@azure-tools/codegen'; import { Dictionary, values } from '@azure-tools/linq'; import { uid } from './uid'; -import { Schema, ObjectSchema, Property, SchemaType } from '@azure-tools/codemodel'; +import { Schema, ObjectSchema, Property, SchemaType, isObjectSchema } from '@azure-tools/codemodel'; import { NewEnhancedTypeDeclaration } from '../llcsharp/schema/extended-type-declaration'; import { NewModelClass } from '../llcsharp/model/model-class'; import { NewModelInterface } from '../llcsharp/model/interface'; @@ -138,7 +138,7 @@ export function getPolymorphicBases(schema: Schema): Array { } export function getAllProperties(schema: Schema): Array { - if (schema instanceof ObjectSchema) { + if (isObjectSchema(schema)) { return [...values(schema.parents ? schema.parents.immediate : []).selectMany(getAllProperties), ...values(schema.properties)]; } else { return []; From 4a7d6bd81be497a537623ca1213cee4436b63101 Mon Sep 17 00:00:00 2001 From: derek Date: Fri, 31 Jul 2020 15:45:03 +0800 Subject: [PATCH 2/6] Add more passed test cases --- tests-upgrade/Configuration.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests-upgrade/Configuration.json b/tests-upgrade/Configuration.json index 6ad6ceb5e7..fa0be4b88c 100644 --- a/tests-upgrade/Configuration.json +++ b/tests-upgrade/Configuration.json @@ -9,11 +9,14 @@ "basic-response-multioperation", "basic-spec-required", "basic-spec-root", - "datamodels-datatypes-array", - "component-param", + "component-definitions-local", "component-multiparam", + "component-param", + "component-param-inbody", "component-param-localremote", - "component-param-inbody" + "component-param-remote", + "datamodels-datatypes-array", + "datamodels-datatypes-integer" ], "BlackList": [ "basic-get-querystr", From b14c9d0cc80b3bb56a59abefac53f0d36a9a9bae Mon Sep 17 00:00:00 2001 From: derek Date: Mon, 3 Aug 2020 16:49:59 +0800 Subject: [PATCH 3/6] Add support for allOf, datetime and enable two cases --- powershell/llcsharp/model/model-class.ts | 166 +++++++++--------- powershell/llcsharp/schema/schema-resolver.ts | 5 +- .../plugin-create-inline-properties.ts | 2 +- tests-upgrade/Configuration.json | 4 +- 4 files changed, 90 insertions(+), 87 deletions(-) diff --git a/powershell/llcsharp/model/model-class.ts b/powershell/llcsharp/model/model-class.ts index 6fbf72d031..c80abb95ba 100644 --- a/powershell/llcsharp/model/model-class.ts +++ b/powershell/llcsharp/model/model-class.ts @@ -552,10 +552,10 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { public get schema() { return this.featureImplementation.schema; } /* @internal */ validateMethod?: Method; - /* @internal */ discriminators: Map = new Map(); - /* @internal */ parentModelClasses: Array = new Array(); - /* @internal */ get modelInterface(): ModelInterface { return this.schema.language.csharp?.interfaceImplementation; } - /* @internal */ get internalModelInterface(): ModelInterface { return this.schema.language.csharp?.internalInterfaceImplementation; } + /* @internal */ discriminators: Map = new Map(); + /* @internal */ parentModelClasses: Array = new Array(); + /* @internal */ get modelInterface(): NewModelInterface { return this.schema.language.csharp?.interfaceImplementation; } + /* @internal */ get internalModelInterface(): NewModelInterface { return this.schema.language.csharp?.internalInterfaceImplementation; } /* @internal */ state: NewState; /* @internal */ backingFields = new Array(); @@ -586,8 +586,7 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { // must be a partial class this.partial = true; - //skip-for-time-being - //this.handleDiscriminator(); + this.handleDiscriminator(); // create an interface for this model class if (!this.schema.language.csharp.interfaceImplementation) { @@ -611,12 +610,12 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { // skip-for-time-being // handle parent interface implementation - // if (!this.handleAllOf()) { - // // handle the AdditionalProperties if used - // if (this.schema.additionalProperties) { - // this.dictionaryImpl = new DictionaryImplementation(this).init(); - // } - // } + if (!this.handleAllOf()) { + // handle the AdditionalProperties if used + // if (this.schema.additionalProperties) { + // this.dictionaryImpl = new DictionaryImplementation(this).init(); + // } + } // create the properties for ths schema this.createProperties(); @@ -838,7 +837,7 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { } } - private additionalPropertiesType(aSchema: Schema): TypeDeclaration | undefined { + private additionalPropertiesType(aSchema: NewSchema): TypeDeclaration | undefined { // skip-for-time-being // if (aSchema.additionalProperties) { @@ -859,76 +858,75 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { return undefined; } - // skip-for-time-being - // private handleAllOf() { - // let hasAdditionalPropertiesInParent = false; - // // handle s - // // add an 'implements' for the interface for the allOf. - // for (const { key: eachSchemaIndex, value: eachSchemaValue } of items(this.schema.allOf)) { - // const aSchema = eachSchemaValue; - // const aState = this.state.path('allOf', eachSchemaIndex); - - // const td = this.state.project.modelsNamespace.resolveTypeDeclaration(aSchema, true, aState); - // const parentClass = (aSchema.details.csharp.classImplementation); - // const className = parentClass.fullName; - // const fieldName = camelCase(deconstruct(className.replace(/^.*\./, ''))); - - // // add the interface as a parent to our interface. - // const iface = aSchema.details.csharp.interfaceImplementation; - - // // add a field for the inherited values - // const backingField = this.addField(new Field(`__${fieldName}`, td, { initialValue: `new ${className}()`, access: Access.Private, description: `Backing field for Inherited model ` })); - // this.backingFields.push({ - // className, - // typeDeclaration: td, - // field: backingField - // }); - // this.validationStatements.add(td.validatePresence(this.validationEventListener, backingField)); - // this.validationStatements.add(td.validateValue(this.validationEventListener, backingField)); - - // this.internalModelInterface.interfaces.push(aSchema.details.csharp.internalInterfaceImplementation); - // this.modelInterface.interfaces.push(iface); - - // // - // const addlPropType = this.additionalPropertiesType(aSchema); - // if (addlPropType) { - // this.dictionaryImpl = new DictionaryImplementation(this).init(addlPropType, backingField); - // hasAdditionalPropertiesInParent = true; - // } - // } - // return hasAdditionalPropertiesInParent; - // } - - // private handleDiscriminator() { - // if (this.schema.discriminator) { - // // this has a discriminator property. - // // our children are expected to tell us who they are - // this.isPolymorphic = true; - // // we'll add a deserializer factory method a bit later.. - // } - - // if (this.schema.details.csharp.discriminatorValue) { - // // we have a discriminator value, and we should tell our parent who we are so that they can build a proper deserializer method. - // // um. just how do we *really* know which allOf is polymorphic? - // // that's really sad. - // for (const { key: eachAllOfIndex, value: eachAllOfValue } of items(this.schema.allOf)) { - // const parentSchema = eachAllOfValue; - // const aState = this.state.path('allOf', eachAllOfIndex); - - // // ensure the parent schema has it's class created first. - // this.state.project.modelsNamespace.resolveTypeDeclaration(parentSchema, true, aState); - - // const parentClass = parentSchema.details.csharp.classImplementation; - // if (parentClass.isPolymorphic) { - // // remember this class for later. - // this.parentModelClasses.push(parentClass); - - // // tell that parent who we are. - // parentClass.addDiscriminator(this.schema.details.csharp.discriminatorValue, this); - // } - // } - // } - // } + private handleAllOf() { + let hasAdditionalPropertiesInParent = false; + // handle s + // add an 'implements' for the interface for the allOf. + for (const { key: eachSchemaIndex, value: eachSchemaValue } of items(this.schema.parents?.immediate)) { + const aSchema = eachSchemaValue; + const aState = this.state.path('allOf', eachSchemaIndex); + + const td = this.state.project.modelsNamespace.NewResolveTypeDeclaration(aSchema, true, aState); + const parentClass = (aSchema.language.csharp?.classImplementation); + const className = parentClass.fullName; + const fieldName = camelCase(deconstruct(className.replace(/^.*\./, ''))); + + // add the interface as a parent to our interface. + const iface = aSchema.language.csharp?.interfaceImplementation; + + // add a field for the inherited values + const backingField = this.addField(new Field(`__${fieldName}`, td, { initialValue: `new ${className}()`, access: Access.Private, description: `Backing field for Inherited model ` })); + this.backingFields.push({ + className, + typeDeclaration: td, + field: backingField + }); + this.validationStatements.add(td.validatePresence(this.validationEventListener, backingField)); + this.validationStatements.add(td.validateValue(this.validationEventListener, backingField)); + + this.internalModelInterface.interfaces.push(aSchema.language.csharp?.internalInterfaceImplementation); + this.modelInterface.interfaces.push(iface); + + // + const addlPropType = this.additionalPropertiesType(aSchema); + if (addlPropType) { + // this.dictionaryImpl = new DictionaryImplementation(this).init(addlPropType, backingField); + // hasAdditionalPropertiesInParent = true; + } + } + return hasAdditionalPropertiesInParent; + } + + private handleDiscriminator() { + if (this.schema.discriminator) { + // this has a discriminator property. + // our children are expected to tell us who they are + this.isPolymorphic = true; + // we'll add a deserializer factory method a bit later.. + } + + if (this.schema.language.csharp?.discriminatorValue) { + // we have a discriminator value, and we should tell our parent who we are so that they can build a proper deserializer method. + // um. just how do we *really* know which allOf is polymorphic? + // that's really sad. + for (const { key: eachAllOfIndex, value: eachAllOfValue } of items(this.schema.parents?.immediate)) { + const parentSchema = eachAllOfValue; + const aState = this.state.path('allOf', eachAllOfIndex); + + // ensure the parent schema has it's class created first. + this.state.project.modelsNamespace.NewResolveTypeDeclaration(parentSchema, true, aState); + + const parentClass = parentSchema.language.csharp?.classImplementation; + if (parentClass.isPolymorphic) { + // remember this class for later. + this.parentModelClasses.push(parentClass); + + // tell that parent who we are. + parentClass.addDiscriminator(this.schema.language.csharp.discriminatorValue, this); + } + } + } + } private addHeaderDeserializer() { const avp = getAllVirtualProperties(this.schema.language.csharp?.virtualProperties); const headers = new Parameter('headers', System.Net.Http.Headers.HttpResponseHeaders); @@ -960,7 +958,7 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { return this.featureImplementation.validatePresence(eventListener, property); } - public addDiscriminator(discriminatorValue: string, modelClass: ModelClass) { + public addDiscriminator(discriminatorValue: string, modelClass: NewModelClass) { this.discriminators.set(discriminatorValue, modelClass); // tell any polymorphic parents incase we're doing subclass of a subclass. diff --git a/powershell/llcsharp/schema/schema-resolver.ts b/powershell/llcsharp/schema/schema-resolver.ts index b33b5ae2d0..0885d402d7 100644 --- a/powershell/llcsharp/schema/schema-resolver.ts +++ b/powershell/llcsharp/schema/schema-resolver.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { codeModelSchema, ArraySchema, CodeModel, Schema as NewSchema, StringSchema, BooleanSchema, NumberSchema, ByteArraySchema, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, VirtualParameter, getAllProperties, ImplementationLocation, OperationGroup, Request, SchemaContext, ConstantSchema, ChoiceSchema } from '@azure-tools/codemodel'; +import { codeModelSchema, ArraySchema, CodeModel, Schema as NewSchema, StringSchema, BooleanSchema, NumberSchema, ByteArraySchema, DateTimeSchema, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, VirtualParameter, getAllProperties, ImplementationLocation, OperationGroup, Request, SchemaContext, ConstantSchema, ChoiceSchema } from '@azure-tools/codemodel'; import { ModelState, codemodel, IntegerFormat, NumberFormat, StringFormat, JsonType } from '@azure-tools/codemodel-v3'; import { Schema } from '../code-model'; @@ -186,6 +186,9 @@ export class NewSchemaDefinitionResolver { } + case SchemaType.DateTime: + return new NewDateTime(schema, required); + case SchemaType.Boolean: return new NewBoolean(schema, required); diff --git a/powershell/plugins/plugin-create-inline-properties.ts b/powershell/plugins/plugin-create-inline-properties.ts index 061b706cc9..84656151f9 100644 --- a/powershell/plugins/plugin-create-inline-properties.ts +++ b/powershell/plugins/plugin-create-inline-properties.ts @@ -238,7 +238,7 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array, thr property: inlinedProperty.property, private: inlinedProperty.private, nameComponents: components, - nameOptions: getNameOptions(inlinedProperty.property.schema.details.default.name, components), + nameOptions: getNameOptions(inlinedProperty.property.schema.language.default.name, components), accessViaProperty: privateProperty, accessViaMember: inlinedProperty, accessViaSchema: schema, diff --git a/tests-upgrade/Configuration.json b/tests-upgrade/Configuration.json index fa0be4b88c..19d490b195 100644 --- a/tests-upgrade/Configuration.json +++ b/tests-upgrade/Configuration.json @@ -9,6 +9,7 @@ "basic-response-multioperation", "basic-spec-required", "basic-spec-root", + "component-definitions-combined", "component-definitions-local", "component-multiparam", "component-param", @@ -16,7 +17,8 @@ "component-param-localremote", "component-param-remote", "datamodels-datatypes-array", - "datamodels-datatypes-integer" + "datamodels-datatypes-integer", + "datamodels-datatypes-string" ], "BlackList": [ "basic-get-querystr", From 4d348a18d53706a2ad5610622ec13c047ad5ecc9 Mon Sep 17 00:00:00 2001 From: derek Date: Tue, 4 Aug 2020 17:22:40 +0800 Subject: [PATCH 4/6] initial poly support --- powershell/llcsharp/model/model-class-json.ts | 19 +++++++++---------- powershell/llcsharp/model/model-class.ts | 6 +++--- powershell/llcsharp/model/namespace.ts | 5 +++++ .../plugin-create-inline-properties.ts | 6 +++--- powershell/utils/schema.ts | 6 ++---- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/powershell/llcsharp/model/model-class-json.ts b/powershell/llcsharp/model/model-class-json.ts index 0bb3ebc820..25ff325813 100644 --- a/powershell/llcsharp/model/model-class-json.ts +++ b/powershell/llcsharp/model/model-class-json.ts @@ -389,16 +389,15 @@ export class NewJsonSerializableClass extends Class { yield If(Not(json.check), Return(dotnet.Null)); yield '// Polymorphic type -- select the appropriate constructor using the discriminator'; /** go thru the list of polymorphic values for the discriminator, and call the target class's constructor for that */ - // skip-for-time-being - // if ($this.schema.discriminator) { - // yield Switch(toExpression(`json.StringProperty("${$this.schema.discriminator.propertyName}")`), function* () { - // for (const { key, value } of items(d)) { - // yield TerminalCase(`"${key}"`, function* () { - // yield Return(value.new(json)); - // }); - // } - // }); - // } + if ($this.schema.discriminator) { + yield Switch(toExpression(`json.StringProperty("${$this.schema.discriminator.property.serializedName}")`), function* () { + for (const { key, value } of items(d)) { + yield TerminalCase(`"${key}"`, function* () { + yield Return(value.new(json)); + }); + } + }); + } yield Return($this.new(json, toExpression($excludes.substring(1)))); } else { // just tell it to create the instance (providing that it's a JSonObject) diff --git a/powershell/llcsharp/model/model-class.ts b/powershell/llcsharp/model/model-class.ts index c80abb95ba..e9a90f7d6d 100644 --- a/powershell/llcsharp/model/model-class.ts +++ b/powershell/llcsharp/model/model-class.ts @@ -905,11 +905,11 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { // we'll add a deserializer factory method a bit later.. } - if (this.schema.language.csharp?.discriminatorValue) { + if (this.schema.discriminatorValue) { // we have a discriminator value, and we should tell our parent who we are so that they can build a proper deserializer method. // um. just how do we *really* know which allOf is polymorphic? // that's really sad. - for (const { key: eachAllOfIndex, value: eachAllOfValue } of items(this.schema.parents?.immediate)) { + for (const { key: eachAllOfIndex, value: eachAllOfValue } of items(this.schema.parents?.all)) { const parentSchema = eachAllOfValue; const aState = this.state.path('allOf', eachAllOfIndex); @@ -922,7 +922,7 @@ export class NewModelClass extends Class implements NewEnhancedTypeDeclaration { this.parentModelClasses.push(parentClass); // tell that parent who we are. - parentClass.addDiscriminator(this.schema.language.csharp.discriminatorValue, this); + parentClass.addDiscriminator(this.schema.discriminatorValue, this); } } } diff --git a/powershell/llcsharp/model/namespace.ts b/powershell/llcsharp/model/namespace.ts index a437aa8ce5..8f1dbe0d54 100644 --- a/powershell/llcsharp/model/namespace.ts +++ b/powershell/llcsharp/model/namespace.ts @@ -184,6 +184,11 @@ export class NewModelsNamespace extends Namespace { this.NewResolveTypeDeclaration(schema, true, state); } } + if (schemas.sealedChoices) { + for (const schema of schemas.sealedChoices) { + this.NewResolveTypeDeclaration(schema, true, state); + } + } //todo, need to add support for other types } diff --git a/powershell/plugins/plugin-create-inline-properties.ts b/powershell/plugins/plugin-create-inline-properties.ts index 84656151f9..c3fa126184 100644 --- a/powershell/plugins/plugin-create-inline-properties.ts +++ b/powershell/plugins/plugin-create-inline-properties.ts @@ -128,7 +128,7 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array, thr originalContainingSchema: virtualProperty.originalContainingSchema, description: virtualProperty.description, alias: [], - required: virtualProperty.required, //|| !!values(schema.required).first(each => !!each && !!each.toLowerCase && each.toLowerCase() === virtualProperty.property.details.default.name.toLowerCase()), + required: virtualProperty.required || !!values(>virtualProperty.originalContainingSchema.properties).first(each => !!each && !!each.required && !!each.serializedName && each.serializedName.toLowerCase() === virtualProperty.property.language.default.name.toLowerCase()), sharedWith: virtualProperty.sharedWith, }; // add it to the list of virtual properties that share this property. @@ -190,7 +190,7 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array, thr description: property.summary || '', originalContainingSchema: schema, alias: [], - required: property.language.default.required, + required: !!property.required, }; virtualProperties.owned.push(privateProperty); @@ -268,7 +268,7 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array, thr description: property.summary || '', originalContainingSchema: schema, alias: [], - required: property.language.default.required + required: !!property.required }); } diff --git a/powershell/utils/schema.ts b/powershell/utils/schema.ts index c4117d84a6..b5ccf61d85 100644 --- a/powershell/utils/schema.ts +++ b/powershell/utils/schema.ts @@ -130,11 +130,9 @@ export interface SchemaDetails extends ImplementationDetails { // } // } -export function getPolymorphicBases(schema: Schema): Array { +export function getPolymorphicBases(schema: ObjectSchema): Array { // are any of my parents polymorphic directly, or any of their parents? - // skip-for-time-being - // return [...values(schema).where(parent => parent.discriminator ? true : false), ...values(schema.allOf).selectMany(getPolymorphicBases)]; - return []; + return [...values(schema.parents?.all).where(parent => (parent).discriminator ? true : false)]; } export function getAllProperties(schema: Schema): Array { From 8a2d30c0b15adc86b86f9dec788552e2fd5ddc8f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Aug 2020 09:56:08 +0800 Subject: [PATCH 5/6] Add a test for polymorphism --- tests-upgrade/Configuration.json | 1 + tests-upgrade/{basic-poly => basic-polymorphism}/readme.md | 0 tests-upgrade/{basic-poly => basic-polymorphism}/swagger.json | 0 3 files changed, 1 insertion(+) rename tests-upgrade/{basic-poly => basic-polymorphism}/readme.md (100%) rename tests-upgrade/{basic-poly => basic-polymorphism}/swagger.json (100%) diff --git a/tests-upgrade/Configuration.json b/tests-upgrade/Configuration.json index 19d490b195..f74ae0b382 100644 --- a/tests-upgrade/Configuration.json +++ b/tests-upgrade/Configuration.json @@ -9,6 +9,7 @@ "basic-response-multioperation", "basic-spec-required", "basic-spec-root", + "basic-polymorphism", "component-definitions-combined", "component-definitions-local", "component-multiparam", diff --git a/tests-upgrade/basic-poly/readme.md b/tests-upgrade/basic-polymorphism/readme.md similarity index 100% rename from tests-upgrade/basic-poly/readme.md rename to tests-upgrade/basic-polymorphism/readme.md diff --git a/tests-upgrade/basic-poly/swagger.json b/tests-upgrade/basic-polymorphism/swagger.json similarity index 100% rename from tests-upgrade/basic-poly/swagger.json rename to tests-upgrade/basic-polymorphism/swagger.json From 5e3697ace1de0c37b0f3ff4225b90b6d346e5033 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Aug 2020 15:59:01 +0800 Subject: [PATCH 6/6] Add support for uuid and duration --- powershell/llcsharp/schema/schema-resolver.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/powershell/llcsharp/schema/schema-resolver.ts b/powershell/llcsharp/schema/schema-resolver.ts index b8ddd1006e..7b5ffdf487 100644 --- a/powershell/llcsharp/schema/schema-resolver.ts +++ b/powershell/llcsharp/schema/schema-resolver.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { codeModelSchema, ArraySchema, CodeModel, Schema as NewSchema, StringSchema, BooleanSchema, NumberSchema, ByteArraySchema, DateTimeSchema, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, VirtualParameter, getAllProperties, ImplementationLocation, OperationGroup, Request, SchemaContext, ConstantSchema, ChoiceSchema } from '@azure-tools/codemodel'; +import { codeModelSchema, ArraySchema, CodeModel, Schema as NewSchema, StringSchema, BooleanSchema, NumberSchema, ByteArraySchema, DateTimeSchema, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, VirtualParameter, getAllProperties, ImplementationLocation, OperationGroup, Request, SchemaContext, ConstantSchema, ChoiceSchema, DurationSchema } from '@azure-tools/codemodel'; import { ModelState, codemodel, IntegerFormat, NumberFormat, StringFormat, JsonType } from '@azure-tools/codemodel-v3'; import { Schema } from '../code-model'; @@ -186,7 +186,10 @@ export class NewSchemaDefinitionResolver { return new NewString(schema, required); } - + case SchemaType.Duration: + return new NewDuration(schema, required); + case SchemaType.Uuid: + return new NewUuid(schema, required); case SchemaType.DateTime: return new NewDateTime(schema, required);