Skip to content

Commit

Permalink
Change the property names to be lower case letter in the tspCodeModel…
Browse files Browse the repository at this point in the history
….json (#4331)

Fixes Azure/autorest.csharp#4715

This PR changes the property names for models and enums in the
`tspCodeModel.json` to be lower cases to align convention and the type
definitions in TCGC.
clients and operations are untouched in this PR, we could make follow up
on those later.
  • Loading branch information
ArcturusZhang authored Sep 6, 2024
1 parent d836c42 commit 89e19ef
Show file tree
Hide file tree
Showing 62 changed files with 15,084 additions and 14,079 deletions.
4 changes: 2 additions & 2 deletions packages/http-client-csharp/emitter/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ async function execAsync(

function transformJSONProperties(this: any, key: string, value: any): any {
// convertUsageNumbersToStrings
if (this["Kind"] === "model" || this["Kind"] === "enum") {
if (key === "Usage" && typeof value === "number") {
if (this["kind"] === "model" || this["kind"] === "enum") {
if (key === "usage" && typeof value === "number") {
if (value === 0) {
return "None";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
SdkServiceMethod,
SdkType,
UsageFlags,
getAllModels,
} from "@azure-tools/typespec-client-generator-core";
import { getDoc } from "@typespec/compiler";
import { NetEmitterOptions, resolveOptions } from "../options.js";
Expand All @@ -28,9 +27,6 @@ import { fromSdkServiceMethod, getParameterDefaultValue } from "./operation-conv
import { processServiceAuthentication } from "./service-authentication.js";

export function createModel(sdkContext: SdkContext<NetEmitterOptions>): CodeModel {
// initialize tcgc model
if (!sdkContext.operationModelsMap) getAllModels(sdkContext);

const sdkPackage = sdkContext.sdkPackage;

const sdkTypeMap: SdkTypeMap = {
Expand Down Expand Up @@ -155,9 +151,9 @@ export function createModel(sdkContext: SdkContext<NetEmitterOptions>): CodeMode
const isEndpoint = parameter.name === endpointVariableName;
const parameterType: InputType = isEndpoint
? {
Kind: "url",
Name: "url",
CrossLanguageDefinitionId: "TypeSpec.url",
kind: "url",
name: "url",
crossLanguageDefinitionId: "TypeSpec.url",
}
: fromSdkType(parameter.type, sdkContext, sdkTypeMap); // TODO: consolidate with converter.fromSdkEndpointType
parameters.push({
Expand Down
Loading

0 comments on commit 89e19ef

Please sign in to comment.