-
Notifications
You must be signed in to change notification settings - Fork 75
Add PowerPlatformSpecGeneratorPlugin and configuration schema #1184
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
base: main
Are you sure you want to change the base?
Conversation
- Implemented the PowerPlatformSpecGeneratorPlugin to generate OpenAPI specifications from recorded requests. - Added configuration options including inclusion of OPTIONS requests, specification format (JSON/YAML), and contact/connector metadata. - Created a JSON schema for validating the plugin's configuration settings.
@dotnet-policy-service agree |
@dotnet-policy-service agree |
Thanks for the PR! As we're still working on this, let me mark it as draft so that we don't merge it while it's still in progress |
Rather than duplicating the logic, we can build on top of the existing plugin and add post-processing of the generated spec. For example, we could add a new virtual method right before this line:
Before we store the path item, we run some extra logic on it, and only then add it. Let's see if this is granular enough for our needs or if we'd need to introduce hooks further down the hierarchy. For reference: we use a similar approach in the MockResponsePlugin where we have two virtual methods dev-proxy/dev-proxy-plugins/Mocks/MockResponsePlugin.cs Lines 294 to 308 in 4587a22
|
… recorded requests - Implemented PowerPlatformSpecGeneratorPlugin to create OpenAPI specifications based on intercepted HTTP requests. - Configured plugin to handle various request types, including OPTIONS, and to serialize specs in JSON or YAML formats. - Integrated language model for generating operation IDs, summaries, and descriptions based on request metadata. - Added support for parameterization of request paths and dynamic generation of OpenAPI schemas from request bodies. - Included logging for better traceability and debugging during the spec generation process. - Established a report structure to store generated spec details for further use by other plugins.
…eneratorPlugin with enhanced path item processing
…bilities - Refactored OpenApiSpecGeneratorPluginConfiguration to be non-sealed for extensibility. - Added ProcessOpenApiDocument method to allow derived plugins to modify OpenAPI documents before serialization. - Implemented PowerPlatformOpenApiSpecGeneratorPlugin to utilize new post-processing features, including setting contact info and generating metadata. - Introduced methods for generating operation IDs, summaries, and descriptions using language model completions. - Added JSON schema for PowerPlatformOpenApiSpecGeneratorPlugin configuration, including new properties for contact and connector metadata.
…arameter handling in PowerPlatformOpenApiSpecGeneratorPlugin
…ML documentation and improved path item processing
…y for derived plugins
@waldekmastykarz I made updates based upon your suggestions. Enhancements to
|
Cool @rwilson504! We'll review it asap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Initial draft for a Power Platform–specific OpenAPI spec generator plugin with a new JSON schema for configuration and extension hooks in the existing generator.
- Adds a JSON schema for validating PowerPlatformOpenApiSpecGeneratorPlugin settings
- Updates
OpenApiSpecGeneratorPlugin
to support post-processing hooks via virtual methods - Adjusts class sealing to allow inheritance and customization
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
schemas/v0.29.0/powerplatformopenapispecgeneratorplugin.schema.json | Adds JSON schema for plugin configuration |
DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs | Exposes ProcessPathItem /ProcessOpenApiDocument hooks and updates class sealing |
Comments suppressed due to low confidence (1)
schemas/v0.29.0/powerplatformopenapispecgeneratorplugin.schema.json:24
- The description refers to "request headers" but the property name is "includeResponseHeaders." Update the description to reference response headers for consistency.
"description": "Determines whether to include request headers in the generated OpenAPI spec. Default: false."
schemas/v0.29.0/powerplatformopenapispecgeneratorplugin.schema.json
Outdated
Show resolved
Hide resolved
schemas/v0.29.0/powerplatformopenapispecgeneratorplugin.schema.json
Outdated
Show resolved
Hide resolved
@@ -50,14 +50,14 @@ public enum SpecFormat | |||
Yaml | |||
} | |||
|
|||
public sealed class OpenApiSpecGeneratorPluginConfiguration | |||
public class OpenApiSpecGeneratorPluginConfiguration | |||
{ | |||
public bool IncludeOptionsRequests { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration class doesn't include properties for includeResponseHeaders, contact, and connectorMetadata, which are defined in the JSON schema. Add these properties so the plugin can bind the full configuration.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start! Let's do a couple of adjustment. Specifically for prompts, let's evaluate how well they work with our default model. Here's some more information how you could do it: https://blog.mastykarz.nl/benchmark-models-openai-compatible-apis/
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
DevProxy.Plugins/Generation/PowerPlatformOpenApiSpecGeneratorPlugin.cs
Outdated
Show resolved
Hide resolved
/// <param name="defaultTitle">The default title to use if LLM generation fails.</param> | ||
private async Task<string> GetOpenApiTitleAsync(string defaultTitle) | ||
{ | ||
var prompt = $@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this logic actually work? The default title that we pass is serverUrl API
. If not specified, we fallback to API
. How would an LLM be able to generate an API title from a string like API
? A URL is more likely, but even then it might be a stretch for the generated string to match our requirements. Is there any other information that we could use to ensure we get closer to what we need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I'm going to update this to set the serverUrl as the default. I'll think more on what other information I can pass to this.
/// <param name="parameterName">The parameter name.</param> | ||
/// <param name="location">The parameter location.</param> | ||
/// <returns>The generated summary.</returns> | ||
private async Task<string> GenerateParameterSummaryAsync(string parameterName, ParameterLocation? location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different from GenerateParameterDescriptionAsync
? Is the only difference the length? If so, I suggest that we create a method to get the description and then shorten to less than 80 chars.
…ev-proxy into PowerPlatformPlugin
…es and adjust schema to reflect array type
…cifications, enhancing metadata handling and API documentation generation
…es and improve URL validation
…d-by extension from the OpenAPI document
… new ToOpenApiContact method
…neratorPlugin to use async methods for processing path items and documents
…etion for operation summaries and add prompt file
…add new powerplat.json configuration file
…hItem and improve response header clearing logic
…schema for clarity and consistency
…ratorPlugin schema for clarity
…nd remove unnecessary return value
…ods to use prompt file parameter and improve method visibility
…atorPlugin for improved operation ID and description generation; streamline prompt files for parameter and response handling; enhance API title generation logic; remove unused prompt files.
Here is my initial draft for a Power Platform Plugin. It needs to be implemented better either through post processing or inheritance from the OpenAPI plugin but wanted to overriding the OpenAPI plugin to shows the differences between a normal OpenAPI file and a Power Platform formatted OpenAPI file. Will need some feedback.
#1183