Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ jobs:
${{ github.workspace }}/build-artifacts/packages/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_API_KEY }}
--skip-duplicate
--skip-duplicate
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,11 @@ TempTypeSpecFiles/
# Artifacts from the generator
tspCodeModel.json
Configuration.json

# Base specification files
specification/base/

# Generator default TypeSpec output
codegen/tsp-output/
codegen/temp/
codegen/emitter/temp/tsconfig.tsbuildinfo
831 changes: 2 additions & 829 deletions api/OpenAI.net8.0.cs

Large diffs are not rendered by default.

127 changes: 2 additions & 125 deletions api/OpenAI.netstandard2.0.cs

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions codegen/emitter/src/emitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { EmitContext } from "@typespec/compiler";

import {
$onEmit as $OnMGCEmit,
CSharpEmitterOptions
} from "@typespec/http-client-csharp";

export async function $onEmit(context: EmitContext<CSharpEmitterOptions>) {
context.options["generator-name"] = "OpenAILibraryGenerator";
context.options["emitter-extension-path"] = import.meta.url;
await $OnMGCEmit(context);
}
1 change: 1 addition & 0 deletions codegen/emitter/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./emitter.js";
22 changes: 22 additions & 0 deletions codegen/generator/OpenAI.Library.Plugin.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenAI.Library.Plugin", "src\OpenAI.Library.Plugin.csproj", "{E46178E4-F3F0-4E2F-8D42-A7F021B23E63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
24 changes: 24 additions & 0 deletions codegen/generator/src/OpenAI.Library.Plugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>OpenAI.Microsoft.Generator.CSharp.ClientModel.Plugin</RootNamespace>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250626.7" />
</ItemGroup>

<!-- Copy output to package dist path for local execution and -->
<Target Name="CopyForNpmPackage" AfterTargets="Build">
<Message Text="Copying output to dist path" Importance="high" />
<ItemGroup>
<SourceDir Include="$(OutputPath)**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(SourceDir)" DestinationFolder="$(MSBuildThisFileDirectory)..\..\dist\generator\%(RecursiveDir)" />
<Copy SourceFiles="..\..\..\node_modules\@typespec\http-client-csharp\dist\generator\Microsoft.TypeSpec.Generator.runtimeconfig.json" DestinationFolder="$(MSBuildThisFileDirectory)..\..\dist\generator" />
</Target>

</Project>
43 changes: 43 additions & 0 deletions codegen/generator/src/OpenAILibraryGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.ComponentModel.Composition;
using Microsoft.TypeSpec.Generator;
using Microsoft.TypeSpec.Generator.ClientModel;
using OpenAILibraryPlugin.Visitors;

namespace OpenAILibraryPlugin
{
[Export(typeof(CodeModelGenerator))]
[ExportMetadata("GeneratorName", nameof(OpenAILibraryGenerator))]
public class OpenAILibraryGenerator : ScmCodeModelGenerator
{
private static OpenAILibraryGenerator? s_instance;
internal static OpenAILibraryGenerator Instance => s_instance ?? throw new InvalidOperationException("OpenAILibraryGenerator was not initialized.");

[ImportingConstructor]
public OpenAILibraryGenerator(GeneratorContext context) : base(context)
{
s_instance = this;
}

protected override void Configure()
{
base.Configure();
AddVisitor(new ConstructorFixupVisitor());
AddVisitor(new KindRenameVisitor());
AddVisitor(new VisibilityVisitor());
AddVisitor(new ContentInnerCollectionDefinedVisitor());
AddVisitor(new NonAbstractPublicTypesVisitor());
AddVisitor(new PageOrderRemovalVisitor(this));
AddVisitor(new OmittedTypesVisitor());
AddVisitor(new InvariantFormatAdditionalPropertiesVisitor());
AddVisitor(new OpenAILibraryVisitor());
AddVisitor(new VirtualMessageCreationVisitor());
AddVisitor(new ProhibitedNamespaceVisitor());
AddVisitor(new ExplicitConversionFromClientResultVisitor());
AddVisitor(new ImplicitConversionToBinaryContentVisitor());
AddVisitor(new ModelSerializationVisitor());
AddVisitor(new ExperimentalAttributeVisitor());
AddVisitor(new ModelDirectoryVisitor());
}
}
}
Loading