Skip to content

Commit

Permalink
Generate model for all the dictionaries and add support for unixtime (
Browse files Browse the repository at this point in the history
…#685)

* Enable two test cases, and drop the workaround for x-ms-enum

* Add utils folder include a script to decrypt securestring

* Generate model for all the dictionaries and add support for unixtime
  • Loading branch information
dolauli committed Sep 1, 2020
1 parent 5bfd3a1 commit 7cb3568
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
5 changes: 5 additions & 0 deletions powershell/llcsharp/model/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export class NewModelsNamespace extends Namespace {
this.NewResolveTypeDeclaration(schema, true, <NewState>state);
}
}
if (schemas.dictionaries) {
for (const schema of schemas.dictionaries) {
this.NewResolveTypeDeclaration(schema, true, <NewState>state);
}
}

if (schemas.any) {
for (const schema of schemas.any) {
Expand Down
5 changes: 4 additions & 1 deletion powershell/llcsharp/schema/schema-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, DurationSchema, BinarySchema, DateSchema } from '@azure-tools/codemodel';
import { codeModelSchema, ArraySchema, UnixTimeSchema, 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, BinarySchema, DateSchema } from '@azure-tools/codemodel';

import { ModelState, codemodel, IntegerFormat, NumberFormat, StringFormat, JsonType } from '@azure-tools/codemodel-v3';
import { Schema } from '../code-model';
Expand Down Expand Up @@ -222,6 +222,9 @@ export class NewSchemaDefinitionResolver {
// fallback to int if the format isn't recognized
return new NewNumeric(<NumberSchema>schema, required, required ? 'int' : 'int?');

case SchemaType.UnixTime:
return new NewUnixTime(<UnixTimeSchema>schema, required);

case SchemaType.Number:
switch ((<NumberSchema>schema).precision) {
case 64:
Expand Down
1 change: 1 addition & 0 deletions tests-upgrade/Configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"datamodels-datatypes-integer",
"datamodels-datatypes-string",
"datamodels-datatypes-object",
"datamodels-datatypes-unixtime",
"datamodels-combineschema",
"directive-model",
"directive-tableformat",
Expand Down
10 changes: 10 additions & 0 deletions tests-upgrade/datamodels-datatypes-unixtime/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
require:
- $(this-folder)/../readme.azure.noprofile.md
input-file:
- $(this-folder)/swagger.json

```
76 changes: 76 additions & 0 deletions tests-upgrade/datamodels-datatypes-unixtime/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"swagger": "2.0",
"info": {
"title": "DatabricksClient",
"version": "2018-04-01",
"description": "ARM Databricks"
},
"host": "management.azure.com",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"security": [
{
"azure_auth": [
"user_impersonation"
]
}
],
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
"paths": {
"/subscriptions/resourceGroup": {
"get": {
"tags": [
"Workspaces"
],
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"200": {
"description": "OK-Return workspace."
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "#/definitions/BasicErrorModel"
}
}
}
}
}
},
"definitions": {
"BasicErrorModel": {
"type": "object",
"required": [
"message",
"code"
],
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "integer",
"format": "unixtime"
}
}
}
}
}

0 comments on commit 7cb3568

Please sign in to comment.