question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variation tests not generated for 'application/merge-patch+json' route body

See original GitHub issue

When trying to generate variation tests for a PATCH route, specifying ‘application/merge-patch+json’ in the OAS3 schema seems to block creation of the tests.

Generates tests:

"paths": {
    "/": {
      "patch": {
        "description": "Updates existing item",
        "operationId": "patch-item,
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/patchItem"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Successfully updated the item."
          },
          "400": {
            "$ref": "#/components/responses/400badrequest"
          }
        }
      }
    }
  }

Does not generate tests:

"paths": {
    "/": {
      "patch": {
        "description": "Updates existing item",
        "operationId": "patch-item,
        "requestBody": {
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/patchItem"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Successfully updated the item."
          },
          "400": {
            "$ref": "#/components/responses/400badrequest"
          }
        }
      }
    }
  }

Note that the requestBody content is the only thing different.

The strange thing is that Portman knows about this type, because when it does generate tests, it properly sets the Content-Type header to ‘application/merge-patch+json’ in the generated tests.

Is this a bug, or am I doing something wrong? Thanks.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
yelobcommented, Jun 21, 2022

Thank you for all your hard work, @thim81! You guys have created a really powerful tool!

1reaction
thim81commented, Jun 19, 2022

hi @yelob ,

We are adding improvements to the anyOf, allOf, oneOf support, which we want to finish as part of the new release. Difficult to say about a timeline, I’m hoping to land everything next week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use media type application/json-patch+json · Issue #13 - GitHub
According to the spec, JSON patch documents should really be using media type application/json-patch+json, instead of application/json.
Read more >
Content-Type must be 'application/json-patch+json'
The error is clear. Is there a way to change the content type before perform the request for the JsonServiceClient? This is the...
Read more >
A better way to implement HTTP PATCH operation in REST APIs
Possibly, a more scalable and effective way to write PATCH endpoints in your REST APIs using JSON Patch specification.
Read more >
Update API Objects in Place Using kubectl patch - Kubernetes
Use kubectl patch to update Kubernetes API objects in place. Do a strategic merge patch or a JSON merge patch.
Read more >
Using HttpClient to Send HTTP PATCH Requests in ASP.NET ...
In this article, we are going to learn how to use HttpClient to send HTTP PATCH requests to partially update resources on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found