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.

Operation "delete" is not generating valid Typescript

See original GitHub issue

What are the steps to reproduce this issue?

Orval: ^6.5.3 Type: react-query

I have a method called delete and its not generating correctly.

OpenApiV3.json

"/authorization/{authorizationId}": {
      "delete": {
        "tags": [
          "Authorization"
        ],
        "summary": "Revoke authorization by ID",
        "operationId": "delete_1",
        "parameters": [
          {
            "name": "authorizationId",
            "in": "path",
            "description": "Id of Authorization to revoke",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "203": {
            "description": "Revoked authorization"
          },
          "403": {
            "description": "User not authorized to revoke"
          },
          "404": {
            "description": "Authorization not found or previously revoked"
          }
        },
        "security": [
          {
            "bearer-key": []
          }
        ]
      }
    },

This is generating errors because delete is a reserved word for JSON.

image

Orval Config:

module.exports = {
   authorization: {
     output: {
       mode: 'split',
       target: 'src/query/endpoints/AuthorizationApi.ts',
      schemas: 'src/query/model',
       client: 'react-query',
       mock: false,
     },
     input: {
       target: './authorization-openapi.json',
     },
   },
 };

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Feb 9, 2022

PR https://github.com/anymaniax/orval/pull/314

I used the word overriddenOperationName instead of overrided. But thanks for the suggested fix!

1reaction
anymaniaxcommented, Feb 9, 2022

Otherwise can simply be fixed with this but I am not a big fan of prefixing with a _ Screen Shot 2022-02-09 at 12 11 43

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the logic behind the TypeScript error "The operand of ...
/*When using the delete operator in strictNullChecks, the operand must now be any, unknown, never, or be optional (in that it contains undefined...
Read more >
deleting a prop doesn't invalidate the interface #13783 - GitHub
Type casting should only be used to validate the delete operation. I.e. whether someObject would be valid if we assign it to an...
Read more >
delete operator - JavaScript - MDN Web Docs - Mozilla
The delete operator removes a property from an object. If the property's value is an object and there are no more references to...
Read more >
5 things you need to know about the delete operator in ...
In JavaScript, the delete operator is employed to delete a property of an object. After deleting the actual property, that property won't be ......
Read more >
Documentation - TypeScript 4.0
For concat , the only valid thing we could do in older versions of the ... tuples and arrays even when we don't...
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