[PR #679] [CLOSED] Support examples in properties #1030

Closed
opened 2025-12-29 08:34:24 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/679
Author: @leolplex
Created: 11/5/2021
Status: Closed

Base: masterHead: SupportExamplesInProperties


📝 Commits (2)

  • 9ee7492 Support RequestBody
  • 2460dd5 When the schema properti has an example then it uses the example

📊 Changes

2 files changed (+59 additions, -10 deletions)

View changed files

📝 src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs (+32 -1)
📝 src/WireMock.Net.OpenApiParser/Utils/ExampleValueGenerator.cs (+27 -9)

📄 Description

Hello @StefH,

This PR contains the capability to support examples when it is defined in the properties:

"schemas": {
        "Order": {
          "type": "object",
          "properties": {
            "id": {
              "type": "integer",
              "format": "int64",
              "example": 10
            },
            "petId": {
              "type": "integer",
              "format": "int64",
              "example": 198772
            },
            "quantity": {
              "type": "integer",
              "format": "int32",
              "example": 7
            },
            "shipDate": {
              "type": "string",
              "format": "date-time"
            },
            "status": {
              "type": "string",
              "description": "Order Status",
              "example": "approved",
              "enum": [
                "placed",
                "approved",
                "delivered"
              ]
            },
            "complete": {
              "type": "boolean"
            }
          },
          "xml": {
            "name": "order"
          }
        },
}

The response looks like this:

 "Response": {
            "StatusCode": 200,
            "BodyAsJson": {
                "id": 10,
                "petId": 198772,
                "quantity": 7,
                "shipDate": "2022-08-09T23:23:26.490-05:00",
                "status": "approved",
                "complete": true
            },
            "Headers": {
                "Content-Type": "application/json"
            }
        }

It could be find in the examples that I uploaded before.

Thank you.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/wiremock/WireMock.Net/pull/679 **Author:** [@leolplex](https://github.com/leolplex) **Created:** 11/5/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `SupportExamplesInProperties` --- ### 📝 Commits (2) - [`9ee7492`](https://github.com/wiremock/WireMock.Net/commit/9ee749287345a623bf4f8f4d5b63a3e807b47bfe) Support RequestBody - [`2460dd5`](https://github.com/wiremock/WireMock.Net/commit/2460dd5595422562e763e5090bc937bced027247) When the schema properti has an example then it uses the example ### 📊 Changes **2 files changed** (+59 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs` (+32 -1) 📝 `src/WireMock.Net.OpenApiParser/Utils/ExampleValueGenerator.cs` (+27 -9) </details> ### 📄 Description Hello @StefH, This PR contains the capability to support examples when it is defined in the properties: ``` "schemas": { "Order": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "example": 10 }, "petId": { "type": "integer", "format": "int64", "example": 198772 }, "quantity": { "type": "integer", "format": "int32", "example": 7 }, "shipDate": { "type": "string", "format": "date-time" }, "status": { "type": "string", "description": "Order Status", "example": "approved", "enum": [ "placed", "approved", "delivered" ] }, "complete": { "type": "boolean" } }, "xml": { "name": "order" } }, } ``` The response looks like this: ``` "Response": { "StatusCode": 200, "BodyAsJson": { "id": 10, "petId": 198772, "quantity": 7, "shipDate": "2022-08-09T23:23:26.490-05:00", "status": "approved", "complete": true }, "Headers": { "Content-Type": "application/json" } } ``` It could be find in the examples that I uploaded before. Thank you. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 08:34:24 +01:00
adam closed this issue 2025-12-29 08:34:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#1030