Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tsp namespace for http-client-csharp #5443

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { InputParameter } from "../type/input-parameter.js";
import { InputEnumType, InputModelType, InputType } from "../type/input-type.js";
import { RequestLocation } from "../type/request-location.js";
import { SdkTypeMap } from "../type/sdk-type-map.js";
import { fromSdkType } from "./converter.js";
import { fromSdkType } from "./type-converter.js";
import { Logger } from "./logger.js";
import { navigateModels } from "./model.js";
import { fromSdkServiceMethod, getParameterDefaultValue } from "./operation-converter.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
} from "../type/input-type.js";
import { OperationResponse } from "../type/operation-response.js";
import { SdkTypeMap } from "../type/sdk-type-map.js";
import { fromSdkType } from "./converter.js";
import { fromSdkType } from "./type-converter.js";

export function fromSdkHttpExamples(
sdkContext: SdkContext<NetEmitterOptions>,
Expand Down
2 changes: 1 addition & 1 deletion packages/http-client-csharp/emitter/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { NetEmitterOptions } from "../options.js";
import { InputType } from "../type/input-type.js";
import { LiteralTypeContext } from "../type/literal-type-context.js";
import { SdkTypeMap } from "../type/sdk-type-map.js";
import { fromSdkEnumType, fromSdkModelType, fromSdkType } from "./converter.js";
import { fromSdkEnumType, fromSdkModelType, fromSdkType } from "./type-converter.js";
import { Logger } from "./logger.js";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { OperationResponse } from "../type/operation-response.js";
import { RequestLocation } from "../type/request-location.js";
import { parseHttpRequestMethod } from "../type/request-method.js";
import { SdkTypeMap } from "../type/sdk-type-map.js";
import { fromSdkModelType, fromSdkType } from "./converter.js";
import { fromSdkModelType, fromSdkType } from "./type-converter.js";
import { getExternalDocs, getOperationId } from "./decorators.js";
import { fromSdkHttpExamples } from "./example-converter.js";
import { Logger } from "./logger.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function fromSdkType(
retVar = {
kind: "nullable",
type: inputType,
clientNamespace: sdkType.clientNamespace,
};
break;
case "model":
Expand Down Expand Up @@ -142,6 +143,7 @@ export function fromSdkModelType(
const ourProperty = fromSdkModelProperty(property, {
ModelName: modelTypeName,
Usage: modelType.usage,
ClientNamespace: modelType.clientNamespace,
} as LiteralTypeContext);
propertiesDict.set(property, ourProperty);
}
Expand Down Expand Up @@ -226,6 +228,7 @@ export function fromSdkEnumType(
context,
enumType.__raw as any,
) /* when tcgc provide a way to identify if the access is override or not, we can get the accessibility from the enumType.access,*/,
clientNamespace: enumType.clientNamespace,
deprecation: enumType.deprecation,
summary: enumType.summary,
doc: enumType.doc,
Expand Down Expand Up @@ -303,6 +306,7 @@ function fromUnionType(
kind: "union",
name: union.name,
variantTypes: variantTypes,
clientNamespace: union.clientNamespace,
decorators: union.decorators,
};
}
Expand Down Expand Up @@ -340,6 +344,7 @@ function fromSdkConstantType(
values: values,
crossLanguageDefinitionId: "",
access: undefined,
clientNamespace: literalTypeContext.ClientNamespace,
doc: `The ${enumName}`, // TODO -- what should we put here?
isFixed: false,
isFlags: false,
Expand Down
4 changes: 4 additions & 0 deletions packages/http-client-csharp/emitter/src/type/input-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface InputUnionType extends InputTypeBase {
kind: "union";
name: string;
variantTypes: InputType[];
clientNamespace: string;
}

export function isInputUnionType(type: InputType): type is InputUnionType {
Expand All @@ -91,6 +92,7 @@ export interface InputModelType extends InputTypeBase {
crossLanguageDefinitionId: string;
access?: AccessFlags;
usage: UsageFlags;
clientNamespace: string;
additionalProperties?: InputType;
discriminatorValue?: string;
discriminatedSubtypes?: Record<string, InputModelType>;
Expand Down Expand Up @@ -124,6 +126,7 @@ export interface InputEnumType extends InputTypeBase {
isFlags: boolean;
usage: UsageFlags;
access?: AccessFlags;
clientNamespace: string;
}

export interface InputEnumTypeValue extends InputTypeBase {
Expand All @@ -137,6 +140,7 @@ export interface InputEnumTypeValue extends InputTypeBase {
export interface InputNullableType extends InputTypeBase {
kind: "nullable";
type: InputType;
clientNamespace: string;
}

export function isInputEnumType(type: InputType): type is InputEnumType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface LiteralTypeContext {
ModelName: string;
PropertyName: string;
Usage: UsageFlags;
ClientNamespace: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Naming.UnionEnum",
"isFixed": false,
"isFlags": false,
"usage": "Input,Json",
Expand Down Expand Up @@ -87,6 +88,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Naming.UnionEnum",
"isFixed": false,
"isFlags": false,
"usage": "Input,Json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Structure.Service",
"isFixed": true,
"isFlags": false,
"usage": "Input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Structure.Service",
"isFixed": true,
"isFlags": false,
"usage": "Input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Structure.Service",
"isFixed": true,
"isFlags": false,
"usage": "Input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Structure.Service",
"isFixed": true,
"isFlags": false,
"usage": "Input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"decorators": []
}
],
"clientNamespace": "Client.Structure.Service",
"isFixed": true,
"isFlags": false,
"usage": "Input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}
],
"crossLanguageDefinitionId": "",
"clientNamespace": "Payload.MultiPart",
"doc": "The FileSpecificContentType_contentType",
"isFixed": false,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"decorators": []
}
],
"clientNamespace": "Resiliency.ServiceDriven",
"doc": "Service versions.",
"isFixed": true,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"decorators": []
}
],
"clientNamespace": "Resiliency.ServiceDriven",
"doc": "Service versions",
"isFixed": true,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"decorators": []
}
],
"clientNamespace": "Server.Path.Multiple",
"doc": "Service versions",
"isFixed": true,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"decorators": []
}
],
"clientNamespace": "Server.Versions.Versioned",
"doc": "The version of the API.",
"isFixed": true,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"decorators": []
}
],
"clientNamespace": "",
"isFixed": true,
"isFlags": false,
"usage": "Output",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,8 @@
"name": "float32",
"crossLanguageDefinitionId": "TypeSpec.float32",
"decorators": []
}
},
"clientNamespace": ""
},
"crossLanguageDefinitionId": "TypeSpec.Array",
"decorators": []
Expand Down Expand Up @@ -2224,7 +2225,8 @@
"name": "int32",
"crossLanguageDefinitionId": "TypeSpec.int32",
"decorators": []
}
},
"clientNamespace": ""
},
"crossLanguageDefinitionId": "TypeSpec.Array",
"decorators": []
Expand Down Expand Up @@ -2428,7 +2430,8 @@
"name": "boolean",
"crossLanguageDefinitionId": "TypeSpec.boolean",
"decorators": []
}
},
"clientNamespace": ""
},
"crossLanguageDefinitionId": "TypeSpec.Array",
"decorators": []
Expand Down Expand Up @@ -2632,7 +2635,8 @@
"name": "string",
"crossLanguageDefinitionId": "TypeSpec.string",
"decorators": []
}
},
"clientNamespace": ""
},
"crossLanguageDefinitionId": "TypeSpec.Array",
"decorators": []
Expand Down Expand Up @@ -2832,7 +2836,8 @@
"kind": "nullable",
"type": {
"$ref": "2"
}
},
"clientNamespace": ""
},
"crossLanguageDefinitionId": "TypeSpec.Array",
"decorators": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2327,7 +2327,8 @@
"name": "float32",
"crossLanguageDefinitionId": "TypeSpec.float32",
"decorators": []
}
},
"clientNamespace": ""
},
"decorators": []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"decorators": []
}
],
"clientNamespace": "Type.Enum.Extensible",
"doc": "Days of the week",
"isFixed": false,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"decorators": []
}
],
"clientNamespace": "Type.Enum.Fixed",
"doc": "Days of the week",
"isFixed": true,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"decorators": []
}
],
"clientNamespace": "Type.Model.Inheritance.EnumDiscriminator",
"doc": "extensible enum type for discriminator",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -73,6 +74,7 @@
"decorators": []
}
],
"clientNamespace": "Type.Model.Inheritance.EnumDiscriminator",
"doc": "fixed enum type for discriminator",
"isFixed": true,
"isFlags": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@
},
"crossLanguageDefinitionId": "TypeSpec.Array",
"decorators": []
}
},
"clientNamespace": ""
},
"optional": true,
"readOnly": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}
],
"crossLanguageDefinitionId": "",
"clientNamespace": "Type.Property.AdditionalProperties",
"doc": "The WidgetData2_kind",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -63,6 +64,7 @@
}
],
"crossLanguageDefinitionId": "",
"clientNamespace": "Type.Property.AdditionalProperties",
"doc": "The WidgetData1_kind",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -96,6 +98,7 @@
}
],
"crossLanguageDefinitionId": "",
"clientNamespace": "Type.Property.AdditionalProperties",
"doc": "The WidgetData0_kind",
"isFixed": false,
"isFlags": false,
Expand Down Expand Up @@ -260,6 +263,7 @@
]
}
],
"clientNamespace": "",
"decorators": []
},
"properties": [
Expand Down Expand Up @@ -311,6 +315,7 @@
"$ref": "19"
}
],
"clientNamespace": "",
"decorators": []
},
"properties": [
Expand Down Expand Up @@ -403,6 +408,7 @@
"$ref": "19"
}
],
"clientNamespace": "",
"decorators": []
},
"properties": [
Expand Down Expand Up @@ -451,6 +457,7 @@
"$ref": "19"
}
],
"clientNamespace": "Type.Property.AdditionalProperties",
"decorators": []
},
"properties": [
Expand Down Expand Up @@ -504,6 +511,7 @@
"decorators": []
}
],
"clientNamespace": "",
"decorators": []
},
"properties": [
Expand Down Expand Up @@ -557,6 +565,7 @@
"decorators": []
}
],
"clientNamespace": "",
"decorators": []
},
"properties": [
Expand Down
Loading
Loading