@@ -74,10 +74,17 @@ public async Task GenerateManifestAsync(CancellationToken cancellationToken = de
74
74
var apiManifest = new ApiManifestDocument ( "application" ) ; //TODO add application name
75
75
// pass empty config hash so that its not included in this manifest.
76
76
apiManifest . ApiDependencies . AddOrReplace ( Configuration . ClientClassName , Configuration . ToApiDependency ( string . Empty , TreeNode ? . GetRequestInfo ( ) . ToDictionary ( static x => x . Key , static x => x . Value ) ?? [ ] , WorkingDirectory ) ) ;
77
+ var publisherName = string . IsNullOrEmpty ( OAIDocument . Info ? . Contact ? . Name )
78
+ ? DefaultContactName
79
+ : OAIDocument . Info . Contact . Name ;
80
+ var publisherEmail = string . IsNullOrEmpty ( OAIDocument . Info ? . Contact ? . Email )
81
+ ? DefaultContactEmail
82
+ : OAIDocument . Info . Contact . Email ;
83
+ apiManifest . Publisher = new Publisher ( publisherName , publisherEmail ) ;
77
84
apiManifest . Write ( writer ) ;
78
85
break ;
79
86
case PluginType . OpenAI :
80
- var pluginDocumentV1 = GetV1ManifestDocument ( ) ;
87
+ var pluginDocumentV1 = GetV1ManifestDocument ( descriptionRelativePath ) ;
81
88
pluginDocumentV1 . Write ( writer ) ;
82
89
break ;
83
90
default :
@@ -86,24 +93,24 @@ public async Task GenerateManifestAsync(CancellationToken cancellationToken = de
86
93
await writer . FlushAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
87
94
}
88
95
}
89
- private PluginManifestDocument GetV1ManifestDocument ( )
96
+ private PluginManifestDocument GetV1ManifestDocument ( string openApiDocumentPath )
90
97
{
91
98
var descriptionForHuman = OAIDocument . Info ? . Description . CleanupXMLString ( ) is string d && ! string . IsNullOrEmpty ( d ) ? d : $ "Description for { OAIDocument . Info ? . Title . CleanupXMLString ( ) } ";
92
99
var manifestInfo = ExtractInfoFromDocument ( OAIDocument . Info ) ;
93
100
return new PluginManifestDocument
94
101
{
95
102
SchemaVersion = "v1" ,
96
103
NameForHuman = OAIDocument . Info ? . Title . CleanupXMLString ( ) ,
97
- // TODO name for model ???
104
+ NameForModel = OAIDocument . Info ? . Title . CleanupXMLString ( ) ,
98
105
DescriptionForHuman = descriptionForHuman ,
99
106
DescriptionForModel = manifestInfo . DescriptionForModel ?? descriptionForHuman ,
100
107
Auth = new V1AnonymousAuth ( ) ,
101
108
Api = new Api ( )
102
109
{
103
110
Type = ApiType . openapi ,
104
- URL = Configuration . OpenAPIFilePath
111
+ URL = openApiDocumentPath
105
112
} ,
106
- ContactEmail = OAIDocument . Info ? . Contact ? . Email ,
113
+ ContactEmail = manifestInfo . ContactEmail ,
107
114
LogoUrl = manifestInfo . LogoUrl ,
108
115
LegalInfoUrl = manifestInfo . LegalUrl ,
109
116
} ;
@@ -118,10 +125,10 @@ private PluginManifestDocument GetManifestDocument(string openApiDocumentPath)
118
125
{
119
126
SchemaVersion = "v2" ,
120
127
NameForHuman = OAIDocument . Info ? . Title . CleanupXMLString ( ) ,
121
- // TODO name for model ???
128
+ NameForModel = OAIDocument . Info ? . Title . CleanupXMLString ( ) ,
122
129
DescriptionForHuman = descriptionForHuman ,
123
130
DescriptionForModel = manifestInfo . DescriptionForModel ?? descriptionForHuman ,
124
- ContactEmail = OAIDocument . Info ? . Contact ? . Email ,
131
+ ContactEmail = manifestInfo . ContactEmail ,
125
132
Namespace = Configuration . ClientClassName ,
126
133
LogoUrl = manifestInfo . LogoUrl ,
127
134
LegalInfoUrl = manifestInfo . LegalUrl ,
@@ -150,6 +157,9 @@ private static OpenApiManifestInfo ExtractInfoFromDocument(OpenApiInfo? openApiI
150
157
string ? legalUrl = null ;
151
158
string ? logoUrl = null ;
152
159
string ? privacyUrl = null ;
160
+ string contactEmail = string . IsNullOrEmpty ( openApiInfo . Contact ? . Email )
161
+ ? DefaultContactEmail
162
+ : openApiInfo . Contact . Email ;
153
163
154
164
if ( openApiInfo . Extensions . TryGetValue ( OpenApiDescriptionForModelExtension . Name , out var descriptionExtension ) &&
155
165
descriptionExtension is OpenApiDescriptionForModelExtension extension &&
@@ -162,11 +172,12 @@ descriptionExtension is OpenApiDescriptionForModelExtension extension &&
162
172
if ( openApiInfo . Extensions . TryGetValue ( OpenApiPrivacyPolicyUrlExtension . Name , out var privacyExtension ) && privacyExtension is OpenApiPrivacyPolicyUrlExtension privacy )
163
173
privacyUrl = privacy . Privacy ;
164
174
165
- return new OpenApiManifestInfo ( descriptionForModel , legalUrl , logoUrl , privacyUrl ) ;
175
+ return new OpenApiManifestInfo ( descriptionForModel , legalUrl , logoUrl , privacyUrl , contactEmail ) ;
166
176
167
177
}
168
-
169
- private sealed record OpenApiManifestInfo ( string ? DescriptionForModel = null , string ? LegalUrl = null , string ? LogoUrl = null , string ? PrivacyUrl = null ) ;
178
+ private const string DefaultContactName = "publisher-name" ;
179
+ private const string DefaultContactEmail = "[email protected] " ;
180
+ private sealed record OpenApiManifestInfo ( string ? DescriptionForModel = null , string ? LegalUrl = null , string ? LogoUrl = null , string ? PrivacyUrl = null , string ContactEmail = DefaultContactEmail ) ;
170
181
private static ( OpenApiRuntime [ ] , Function [ ] ) GetRuntimesAndFunctionsFromTree ( OpenApiUrlTreeNode currentNode , string openApiDocumentPath )
171
182
{
172
183
var runtimes = new List < OpenApiRuntime > ( ) ;
0 commit comments