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.

`media-type-examples-override` decorator

See original GitHub issue

Is your feature request related to a problem? Please describe.

To solve the same issue we solved with other decorators.

Most developers are too lazy to define media type examples.

https://github.com/redocly-demo/decorators-demo/pull/1

In the event the OpenAPI file is auto-generated, then there is no reliable way to add examples (without them getting overwritten on the next auto-generation).

Describe the solution you’d like

I’d like to see:

decorators:
  media-type-examples-override:
    operationIds:
      PostPets: ./pet-examples.yaml

Describe alternatives you’ve considered None - I am open to ideas.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
adamaltmancommented, Sep 29, 2022

Yes, it can have multiple examples. However, that’s a good question. It needs to target the response code or the request media type.

So maybe it should be like this:

decorators:
  media-type-examples-override:
    operationIds:
       PostPets:
          request: 
              application/json: ./pet-examples.yaml
          responses: 
            '200': ./pet-examples.yaml
            '400': ./pet-errors-examples.yaml

EDITED

0reactions
IgorKarpiukcommented, Dec 5, 2022

I implemented the second option because it looks more secure

Read more comments on GitHub >

github_iconTop Results From Across the Web

media-type-examples-override - Redocly
This decorator provides a way to "overlay" a new examples over the source so that as the source changes you won't lose your...
Read more >
Override value of custom runtime annotation applied on ...
tl;dr: I'm overriding a method annotation of an interface on a child-child class, but the annotation's value is not being override.
Read more >
PEP 698 – Override Decorator for Static Typing
This PEP proposes adding an @override decorator to the Python type system. This will allow type checkers to prevent a class of bugs...
Read more >
Enforcing the Output MediaType | MuleSoft Documentation
However, as shown in the video media type example, you can use whatever ... This parameter allows the module's user to manually override...
Read more >
Using @Consumes and @Produces to Customize Requests ...
The doGetAsHtml method's @Produces annotation overrides the class-level ... If a resource class is capable of producing more that one MIME media type, ......
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