Skip to content

Commit f9c6089

Browse files
authored
Add support for enum with one value (#666)
* Add databricks, fix several issues * Fixed a completer related issue and add support for credential * Add two m4 configuration and fix some issues * Add support for enum with one value
1 parent 7808ff9 commit f9c6089

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

powershell/llcsharp/schema/schema-resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class NewSchemaDefinitionResolver {
231231
case SchemaType.Constant:
232232
switch ((<ConstantSchema>schema).valueType.type) {
233233
case SchemaType.String:
234-
return new NewEnumImplementation(<StringSchema>schema, required);
234+
return new NewString(schema, required);
235235
case SchemaType.DateTime:
236236
if ((<any>schema).valueType.format === StringFormat.DateTimeRfc1123) {
237237
return new NewDateTime1123(<DateTimeSchema>schema, required);

powershell/plugins/plugin-create-inline-properties.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { codeModelSchema, CodeModel, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, ImplementationLocation, OperationGroup, Request, SchemaContext } from '@azure-tools/codemodel';
6+
import { codeModelSchema, CodeModel, ObjectSchema, ConstantSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, ImplementationLocation, OperationGroup, Request, SchemaContext } from '@azure-tools/codemodel';
77
//import { VirtualParameter } from '@azure-tools/codemodel-v3';
88
import { getPascalIdentifier, removeSequentialDuplicates, pascalCase, fixLeadingNumber, deconstruct, selectName, EnglishPluralizationService, serialize } from '@azure-tools/codegen';
99
import { length, values, } from '@azure-tools/linq';
@@ -270,6 +270,11 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array<string>, thr
270270
alias: [],
271271
required: property.required || property.language.default.required
272272
});
273+
// dolauli, set constant value and make it readonly, if it is constant
274+
if (property.schema.type === SchemaType.Constant) {
275+
property.language.default.readOnly = true;
276+
property.language.default.constantValue = (<ConstantSchema>property.schema).value.value;
277+
}
273278
}
274279

275280
// resolve name collisions.

0 commit comments

Comments
 (0)