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

Support Specification Extensions #638

Open
iwaldman opened this issue Jan 4, 2024 · 1 comment
Open

Support Specification Extensions #638

iwaldman opened this issue Jan 4, 2024 · 1 comment

Comments

@iwaldman
Copy link

iwaldman commented Jan 4, 2024

Do you support or have plans to support Specification Extensions?

For example, I need to include the x-ms-openai-data internal property to help Power Platform do its required processing:

image

@iwaldman
Copy link
Author

iwaldman commented Jan 4, 2024

I was able to implement support for info and operations extensions via the IDocumentFilter.

public class DocumentFilter : IDocumentFilter
{
    public void Apply(IHttpRequestDataObject request, OpenApiDocument document)
    {
        if (!document.Info.Extensions.ContainsKey("x-ms-keywords"))
        {
            document.Info.Extensions.Add(
                "x-ms-keywords",
                new OpenApiArray { new OpenApiString("Acme") }
            );
        }

        var paths = document.Paths;
        foreach (var path in paths)
        {
            var pathItem = path.Value;
            foreach (var operation in pathItem.Operations)
            {
                var operationItem = operation.Value;
                if (!operationItem.Extensions.ContainsKey("x-ms-openai-data"))
                {
                    operationItem.Extensions.Add(
                        "x-ms-openai-data",
                        new OpenApiObject { { "openai-enabled", new OpenApiBoolean(true) } }
                    );
                }
            }
        }
    }
}
` ``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant