Skip to content

Commit 4f5221c

Browse files
authored
Merge pull request Azure#376 from kairu-ms/tsp-aaz-emitter
Improve typespec-aaz models
2 parents 7ee38fa + 254263d commit 4f5221c

29 files changed

+1849
-411
lines changed

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/aaz_dev/command/model/configuration/_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ class CMDArraySchemaBase(CMDSchemaBase):
982982
)
983983
item = CMDSchemaBaseField()
984984

985-
# used to indentify item in array
985+
# used to identify item in array
986986
identifiers = ListType(StringType())
987987

988988
# properties as tags

src/aaz_dev/swagger/model/schema/typespec/operation.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from schematics.models import Model
22
from schematics.types import StringType, ModelType, BooleanType
33
from ..fields import BooleanType
4-
# from ..x_ms_pageable import XmsPageableField
4+
from ..x_ms_pageable import XmsPageableField
55

66
from command.model.configuration import CMDHttpOperation
77

@@ -12,10 +12,7 @@ class TypeSpecOperation(Model):
1212
deserialize_from="operationId",
1313
) # Unique string used to identify the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.
1414

15-
x_ms_pageable = BooleanType(
16-
serialized_name="isPageable",
17-
deserialize_from="isPageable"
18-
)
15+
x_ms_pageable = XmsPageableField(serialized_name="pageable", deserialize_from="pageable")
1916
# x_ms_examples = XmsExamplesField() # TODO:
2017

2118
# MutabilityEnum.Read

src/aaz_dev/swagger/model/schema/x_ms_pageable.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ class XmsPageable(Model):
3030
class XmsPageableField(ModelType):
3131

3232
def __init__(self, **kwargs):
33+
serialized_name=kwargs.pop('serialized_name', 'x-ms-pageable')
34+
deserialize_from=kwargs.pop('deserialize_from', 'x-ms-pageable')
3335
super(XmsPageableField, self).__init__(
3436
XmsPageable,
35-
serialized_name='x-ms-pageable',
36-
deserialize_from='x-ms-pageable',
37+
serialized_name=serialized_name,
38+
deserialize_from=deserialize_from,
3739
**kwargs
3840
)

src/typespec-aaz/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
"@typescript-eslint/eslint-plugin": "^6.0.0",
2020
"@typescript-eslint/parser": "^6.0.0",
2121
"@typespec/library-linter": "workspace:~",
22+
"change-case": "~5.4.4",
2223
"eslint": "^8.57.0",
23-
"typescript": "^5.2.2",
24-
"prettier": "^3.0.3"
24+
"prettier": "^3.0.3",
25+
"typescript": "^5.2.2"
2526
},
2627
"peerDependencies": {
2728
"@azure-tools/typespec-azure-core": "workspace:~",
2829
"@azure-tools/typespec-client-generator-core": "workspace:~",
2930
"@typespec/compiler": "workspace:~",
3031
"@typespec/http": "workspace:~",
32+
"@typespec/openapi": "workspace:~",
3133
"@typespec/rest": "workspace:~",
3234
"@typespec/versioning": "workspace:~"
3335
},

src/typespec-aaz/src/context.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { SdkContext } from "@azure-tools/typespec-client-generator-core";
2+
import { Program, Service } from "@typespec/compiler";
3+
import { MutabilityEnum } from "./model/fields.js";
4+
// import { HttpOperation } from "@typespec/http";
5+
// import { TypeSpecPathItem } from "./model/path_item.js";
6+
7+
export interface AAZEmitterContext {
8+
readonly program: Program;
9+
readonly service: Service;
10+
readonly sdkContext: SdkContext;
11+
readonly apiVersion: string;
12+
}
13+
14+
export interface AAZOperationEmitterContext extends AAZEmitterContext {
15+
readonly operationId: string;
16+
readonly mutability: MutabilityEnum;
17+
// operation: HttpOperation;
18+
// pathItem: TypeSpecPathItem;
19+
}
20+
21+
export interface AAZSchemaEmitterContext extends AAZOperationEmitterContext {
22+
readonly collectionFormat?: string;
23+
deep: number;
24+
}

0 commit comments

Comments
 (0)