Skip to content

Commit

Permalink
mgmt, support flattenProperty (#2529)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Jan 25, 2024
1 parent 171aaf1 commit 95268e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions typespec-extension/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Compatible with compiler 0.52.

- Supported `@clientName` from "@azure-tools/typespec-client-generator-core".
- Supported `@flattenProperty` from "@azure-tools/typespec-client-generator-core".

## 0.12.3 (2024-01-22)

Expand Down
12 changes: 8 additions & 4 deletions typespec-extension/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
SdkClient,
getCrossLanguageDefinitionId,
getClientNameOverride,
shouldFlattenProperty,
} from "@azure-tools/typespec-client-generator-core";
import { fail } from "assert";
import {
Expand Down Expand Up @@ -2277,14 +2278,17 @@ export class CodeModelBuilder {
const schema = this.processSchema(prop, prop.name);
let nullable = isNullableType(prop.type);

let extensions = undefined;
let extensions: Record<string, any> | undefined = undefined;
if (this.isSecret(prop)) {
extensions = {
"x-ms-secret": true,
};
extensions = extensions ?? {};
extensions["x-ms-secret"] = true;
// if the property does not return in response, it had to be nullable
nullable = true;
}
if (shouldFlattenProperty(this.sdkContext, prop)) {
extensions = extensions ?? {};
extensions["x-ms-client-flatten"] = true;
}

return new Property(this.getName(prop), this.getDoc(prop), schema, {
summary: this.getSummary(prop),
Expand Down

0 comments on commit 95268e1

Please sign in to comment.