[PR #662] [CLOSED] Support an Array in the examples. #1019

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

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/662
Author: @leolplex
Created: 10/21/2021
Status: Closed

Base: masterHead: master


📝 Commits (10+)

  • 0b8537b Support edge case: first object, next an array.
  • edf15bf Add mapping to header parameters.
  • 0296d76 Merge branch 'WireMock-Net:master' into master
  • 355c3e7 Refactor the method MapHeadersParameters to MapHeaders
  • 3a1b80f Merge branch 'WireMock-Net:master' into master
  • 75b8eea Refactor method name 'cause is duplicate, only pass httpStatusCode when fail
  • afc5951 Merge branch 'WireMock-Net:master' into master
  • 83bce01 Commit question, how to use 'NotNullOrEmptyMatcher' in Request Header
  • a5c5437 Merge branch 'WireMock-Net:master' into master
  • d9e1dc2 Update OpenApiPathsMapper.cs

📊 Changes

1 file changed (+8 additions, -1 deletions)

View changed files

📝 src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs (+8 -1)

📄 Description

Hello @StefH ,

When the openapi file had an example with array wiremock.net shown this message "Error reading JObject from JsonReader. Current JsonReader item is not an object"

I introduce this change in order to support an Array in the examples.

By the way, thankss a looot for deploy to Nuget the last version it was really useful for me.

Below the openapi file with wich I test:


openapi: 3.0.1
info:
  title: API_Test
  version: v1
paths:
  /WeatherForecast:
    get:
      tags:
        - WeatherForecast
      parameters:
      - in: "header"
        name: X-Correlation-ID
        type: "string"
        required: true
      responses:
        '200':
          description: Success
          content:           
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/WeatherForecast'
  /leolplex:
    get:
      tags:
        - WeatherForecast
      parameters:
      - in: "header"
        name: X-Correlation-ID
        type: "string"
        required: true
      responses:
        '200':
          description: Success
          content:           
            application/json:
              example:
                - date: 2021-10-21T09:13:00.552+00:00
                  temperatureC: 111
                  temperatureF: 111
                  summary: Just-summary
                - date: 2021-10-21T09:13:00.000+00:00
                  temperatureC: 222
                  temperatureF: 222
                  summary: Just-summary2 
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/WeatherForecast'
  /exampleop:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              example:
                id: 1
                name: get food
                completed: false
              schema:
                properties:
                  id:
                    type: integer
                  name:
                    type: string
                  completed:
                    type: boolean
                  completed_at:
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - completed
components:
  schemas:
    WeatherForecast:
      type: object
      properties:
        date:
          type: string
          format: date-time
        temperatureC:
          type: integer
          format: int32
        temperatureF:
          type: integer
          format: int32
          readOnly: true
        summary:
          type: string
          nullable: true
      additionalProperties: false

🔄 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/662 **Author:** [@leolplex](https://github.com/leolplex) **Created:** 10/21/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (10+) - [`0b8537b`](https://github.com/wiremock/WireMock.Net/commit/0b8537b5ebd40c472ae3772a10e071702018da63) Support edge case: first object, next an array. - [`edf15bf`](https://github.com/wiremock/WireMock.Net/commit/edf15bf7796acc5a9c4d4142825eca9121278c97) Add mapping to header parameters. - [`0296d76`](https://github.com/wiremock/WireMock.Net/commit/0296d768307e164626dc522ade64ac65a7d371a4) Merge branch 'WireMock-Net:master' into master - [`355c3e7`](https://github.com/wiremock/WireMock.Net/commit/355c3e71fcbe44428a35bee9658f5bb8ae46a030) Refactor the method MapHeadersParameters to MapHeaders - [`3a1b80f`](https://github.com/wiremock/WireMock.Net/commit/3a1b80f6c2ce502041e6bb90761ae2d7ad8665a5) Merge branch 'WireMock-Net:master' into master - [`75b8eea`](https://github.com/wiremock/WireMock.Net/commit/75b8eea96796c0291c566df7a51817a2d31579c9) Refactor method name 'cause is duplicate, only pass httpStatusCode when fail - [`afc5951`](https://github.com/wiremock/WireMock.Net/commit/afc59513f43f8007f48fa261266c6f754f98093e) Merge branch 'WireMock-Net:master' into master - [`83bce01`](https://github.com/wiremock/WireMock.Net/commit/83bce018c87ea267a9ab113df57f625b69e85963) Commit question, how to use 'NotNullOrEmptyMatcher' in Request Header - [`a5c5437`](https://github.com/wiremock/WireMock.Net/commit/a5c5437e261f6026bbf0ac03a0a91ae6d054312e) Merge branch 'WireMock-Net:master' into master - [`d9e1dc2`](https://github.com/wiremock/WireMock.Net/commit/d9e1dc226865cf7bbf3bc07856d8d4fd7b5e4b83) Update OpenApiPathsMapper.cs ### 📊 Changes **1 file changed** (+8 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs` (+8 -1) </details> ### 📄 Description Hello @StefH , When the openapi file had an example with array wiremock.net shown this message "**Error reading JObject from JsonReader. Current JsonReader item is not an object**" I introduce this change in order to support an Array in the examples. By the way, thankss a looot for deploy to Nuget the last version it was really useful for me. Below the openapi file with wich I test: ``` openapi: 3.0.1 info: title: API_Test version: v1 paths: /WeatherForecast: get: tags: - WeatherForecast parameters: - in: "header" name: X-Correlation-ID type: "string" required: true responses: '200': description: Success content: application/json: schema: type: array items: $ref: '#/components/schemas/WeatherForecast' /leolplex: get: tags: - WeatherForecast parameters: - in: "header" name: X-Correlation-ID type: "string" required: true responses: '200': description: Success content: application/json: example: - date: 2021-10-21T09:13:00.552+00:00 temperatureC: 111 temperatureF: 111 summary: Just-summary - date: 2021-10-21T09:13:00.000+00:00 temperatureC: 222 temperatureF: 222 summary: Just-summary2 schema: type: array items: $ref: '#/components/schemas/WeatherForecast' /exampleop: get: responses: "200": description: OK content: application/json: example: id: 1 name: get food completed: false schema: properties: id: type: integer name: type: string completed: type: boolean completed_at: type: string format: date-time nullable: true required: - id - name - completed components: schemas: WeatherForecast: type: object properties: date: type: string format: date-time temperatureC: type: integer format: int32 temperatureF: type: integer format: int32 readOnly: true summary: type: string nullable: true additionalProperties: false ``` --- <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:22 +01:00
adam closed this issue 2025-12-29 08:34:22 +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#1019