-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
129 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -499,7 +499,7 @@ public void LoadOpenAIPluginManifestWithNoApiUrl() | |
[Fact] | ||
public async Task GenerateOpenAIPluginManifestFromApiManifestAsync() | ||
{ | ||
var openAiPluginManifest = await exampleApiManifest.ToOpenAIPluginManifestAsync(logoUrl: "https://avatars.githubusercontent.com/bar", legalInfoUrl: "https://legalinfo.foobar.com"); | ||
var openAiPluginManifest = await exampleApiManifest.ToOpenAIPluginManifestAsync("https://avatars.githubusercontent.com/bar", "https://legalinfo.foobar.com"); | ||
|
||
Assert.Equal("1.0.0", openAiPluginManifest.SchemaVersion); | ||
Assert.Equal("Mastodon", openAiPluginManifest.NameForHuman); | ||
|
@@ -508,19 +508,15 @@ public async Task GenerateOpenAIPluginManifestFromApiManifestAsync() | |
Assert.Equal("Description for Mastodon.", openAiPluginManifest.DescriptionForModel); | ||
_ = Assert.IsType<ManifestNoAuth>(openAiPluginManifest.Auth); | ||
Assert.Equal("openapi", openAiPluginManifest.Api?.Type); | ||
Assert.Equal("./openapi.json", openAiPluginManifest.Api?.Url); | ||
Assert.Equal(exampleApiManifest.ApiDependencies.FirstOrDefault().Value.ApiDescriptionUrl, openAiPluginManifest.Api?.Url); | ||
Assert.Equal("https://avatars.githubusercontent.com/bar", openAiPluginManifest.LogoUrl); | ||
Assert.Equal("https://legalinfo.foobar.com", openAiPluginManifest.LegalInfoUrl); | ||
} | ||
|
||
[Fact] | ||
public async Task GenerateOpenAIPluginManifestFromApiManifestOfAnApiDependencyAsync() | ||
{ | ||
var openAiPluginManifest = await exampleApiManifest.ToOpenAIPluginManifestAsync( | ||
logoUrl: "https://avatars.githubusercontent.com/bar", | ||
legalInfoUrl: "https://legalinfo.foobar.com", | ||
apiDependencyName: "MicrosoftGraph", | ||
openApiFilePath: "./openapi.yml"); | ||
var openAiPluginManifest = await exampleApiManifest.ToOpenAIPluginManifestAsync("https://avatars.githubusercontent.com/bar", "https://legalinfo.foobar.com", "MicrosoftGraph", "./openapi.yml"); | ||
|
||
Assert.Equal("v1.0", openAiPluginManifest.SchemaVersion); | ||
Assert.Equal("DirectoryObjects", openAiPluginManifest.NameForHuman); | ||
|
@@ -537,11 +533,8 @@ public async Task GenerateOpenAIPluginManifestFromApiManifestOfAnApiDependencyAs | |
[Fact] | ||
public void GenerateOpenAIPluginManifestFromApiManifestWithWrongApiDependency() | ||
{ | ||
_ = Assert.ThrowsAsync<ApiManifestException>(async () => await exampleApiManifest.ToOpenAIPluginManifestAsync( | ||
logoUrl: "https://avatars.githubusercontent.com/bar", | ||
legalInfoUrl: "https://legalinfo.foobar.com", | ||
apiDependencyName: "ContosoApi", | ||
openApiFilePath: "./openapi.yml")); | ||
_ = Assert.ThrowsAsync<ApiManifestException>( | ||
async () => await exampleApiManifest.ToOpenAIPluginManifestAsync("https://avatars.githubusercontent.com/bar", "https://legalinfo.foobar.com", "ContosoApi", "./openapi.yml")); | ||
} | ||
|
||
[Fact] | ||
|
@@ -550,22 +543,13 @@ public void GenerateOpenAIPluginManifestFromApiManifestWithEmptyApiDependencies( | |
var apiManifest = LoadTestApiManifestDocument(); | ||
apiManifest.ApiDependencies.Clear(); | ||
|
||
_ = Assert.ThrowsAsync<ApiManifestException>(async () => await apiManifest.ToOpenAIPluginManifestAsync( | ||
logoUrl: "https://avatars.githubusercontent.com/bar", | ||
legalInfoUrl: "https://legalinfo.foobar.com", | ||
apiDependencyName: "MicrosoftGraph", | ||
openApiFilePath: "./openapi.yml")); | ||
_ = Assert.ThrowsAsync<ApiManifestException>( | ||
async () => await apiManifest.ToOpenAIPluginManifestAsync("https://avatars.githubusercontent.com/bar", "https://legalinfo.foobar.com", "MicrosoftGraph", "./openapi.yml")); | ||
} | ||
|
||
private static OpenAIPluginManifest CreateManifestPlugIn() | ||
{ | ||
var manifest = OpenApiPluginFactory.CreateOpenAIPluginManifest( | ||
schemaVersion: "1.0.0", | ||
nameForHuman: "TestOAuth", | ||
nameForModel: "TestOAuthModel", | ||
logoUrl: "https://avatars.githubusercontent.com/bar", | ||
legalInfoUrl: "https://legalinfo.foobar.com", | ||
contactEmail: "[email protected]"); | ||
var manifest = OpenApiPluginFactory.CreateOpenAIPluginManifest("TestOAuthModel", "TestOAuth", "https://avatars.githubusercontent.com/bar", "[email protected]", "https://legalinfo.foobar.com", "1.0.0"); | ||
manifest.DescriptionForHuman = "SomeHumanDescription"; | ||
manifest.DescriptionForModel = "SomeModelDescription"; | ||
manifest.Auth = new ManifestNoAuth(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Contoso | ||
version: 1.0.0 | ||
tags: [] | ||
paths: | ||
/api/v1/activity: | ||
post: | ||
operationId: contoso_createActivity | ||
parameters: [] | ||
responses: | ||
'200': | ||
description: Success. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Contoso.Activity' | ||
'401': | ||
description: Access is unauthorized. | ||
requestBody: | ||
required: true | ||
content: | ||
application/x-www-form-urlencoded: | ||
schema: | ||
$ref: '#/components/schemas/Contoso.CreateActivityForm' | ||
components: | ||
schemas: | ||
Contoso.Activity: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
required: | ||
- id | ||
- name | ||
Contoso.CreateActivityForm: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
required: | ||
- id | ||
- name | ||
servers: | ||
- url: https://contoso.com/ | ||
description: Server URL. | ||
variables: {} |