Skip to content

Add sample: mock an API from its OpenAPI spec (OpenApiMockResponsePlugin) - #74

Open
waldekmastykarz wants to merge 2 commits into
pnp:mainfrom
waldekmastykarz:openapi-mock-sample
Open

waldekmastykarz wants to merge 2 commits into
pnp:mainfrom
waldekmastykarz:openapi-mock-sample

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Member

Closes #73

Adds the openapi-mock-responses sample, which shows how to mock an API from its OpenAPI spec using Dev Proxy's new OpenApiMockResponsePlugin (dotnet/dev-proxy#2036).

What's included

  • .devproxy/contoso-api.yaml: OpenAPI spec for a fictional Contoso Store API. Some operations have examples and others only have schemas, so you can see every source a response body can come from.
  • .devproxy/devproxyrc.json: enables OpenApiMockResponsePlugin with specFile and turns on languageModel (for example Ollama). When no model is available, the plugin falls back to values based on schema types.
  • README with curl examples and an explanation of how operations are matched, how the status code is picked, where the body comes from, and how responses are cached.
  • assets/sample.json metadata and .vscode/extensions.json.

Notes

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Validation failed!

File: samples/openapi-mock-responses/assets/sample.json

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The sample has a missing screenshot asset, incorrect mock-file metadata, and setup instructions that omit entering the sample directory, which can prevent its configuration from loading.

3 open issues
What changed in this PR

Adds an OpenAPI-driven mocking sample for Dev Proxy, addressing #73 with a fictional Contoso Store API and optional local language model support. The sample targets the unreleased v4.1.0.

Changes:

  • Defines API operations with explicit examples and schema-only responses.
  • Configures OpenApiMockResponsePlugin and documents request matching, response generation, caching, and curl usage.
  • Adds gallery metadata and a recommended VS Code extension.
File Description
samples/​openapi-mock-responses/​README.md Explains setup, usage, and mock response behavior.
samples/​openapi-mock-responses/​assets/​sample.json Adds sample gallery metadata and references.
samples/​openapi-mock-responses/​.vscode/​extensions.json Recommends the Dev Proxy Toolkit extension.
samples/​openapi-mock-responses/​.devproxy/​devproxyrc.json Enables OpenAPI mocking and local language model support.
samples/​openapi-mock-responses/​.devproxy/​contoso-api.yaml Defines product, customer, and order operations and response schemas.

Review effort: Balanced

"name": "screenshot.png",
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/proxy-samples/main/samples/openapi-mock-responses/assets/screenshot.png",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged, and already called out in the PR description. The screenshot can only be captured once Dev Proxy v4.1.0 with OpenApiMockResponsePlugin (dotnet/dev-proxy#2036) is released. It will be added before this PR is merged, so I'm leaving this thread open as a tracker.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz
waldekmastykarz requested a balanced review from Copilot October 31, 2026 10:18
@github-actions

Copy link
Copy Markdown

Validation failed!

File: samples/openapi-mock-responses/assets/sample.json

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The sample relies on unreleased Dev Proxy v4.1.0 and the unmerged plugin in dotnet/dev-proxy#2036, leaving required schema and end-to-end validation unavailable before merge.

1 open issue
2 resolved since last review

Review effort: Balanced

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

Successfully merging this pull request may close these issues.

New sample: mock an API from its OpenAPI spec using OpenApiMockResponsePlugin

2 participants