Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add ResponseSpec(examples=...) #3068

Closed
tuukkamustonen opened this issue Feb 4, 2024 · 4 comments · Fixed by #3100
Closed

Enhancement: Add ResponseSpec(examples=...) #3068

tuukkamustonen opened this issue Feb 4, 2024 · 4 comments · Fixed by #3100
Labels
Enhancement This is a new feature or request Help Wanted 🆘 This is good for people to work on

Comments

@tuukkamustonen
Copy link
Contributor

tuukkamustonen commented Feb 4, 2024

Summary

Support adding custom examples for the response body.

The inbound parameters can be defined via Parameter, but the same does not work for the response body. ResponseSpec only has generate_examples, but it should support also examples for custom ones.

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@tuukkamustonen tuukkamustonen added the Enhancement This is a new feature or request label Feb 4, 2024
@JacobCoffee JacobCoffee added the Help Wanted 🆘 This is good for people to work on label Feb 4, 2024
@tuukkamustonen
Copy link
Contributor Author

Related, any thoughts about supporting Parameter (-like) construct for response annotation?

@get()
def endpoint() -> Annotated[ResponseModel, ResponseSpec(examples=[...])]: ...

@guacs
Copy link
Member

guacs commented Feb 6, 2024

Related, any thoughts about supporting Parameter (-like) construct for response annotation?

@get()
def endpoint() -> Annotated[ResponseModel, ResponseSpec(examples=[...])]: ...

This feels reasonable to me.

tuukkamustonen pushed a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define.

The examples set this way are always generated locally, for each response:

```json
{
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
tuukkamustonen pushed a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
tuukkamustonen pushed a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
tuukkamustonen pushed a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
tuukkamustonen pushed a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
tuukkamustonen added a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
tuukkamustonen added a commit to tuukkamustonen/litestar that referenced this issue Feb 13, 2024
Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Feb 13, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Feb 13, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Feb 13, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
@provinzkraut
Copy link
Member

Closed in #3100

provinzkraut pushed a commit that referenced this issue Feb 13, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Feb 13, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Feb 14, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
ch-iv pushed a commit to ch-iv/litestar that referenced this issue Feb 19, 2024
feat: Support `ResponseSpec(..., examples=[...])` (litestar-org#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Mar 1, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Mar 4, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Mar 9, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
provinzkraut pushed a commit that referenced this issue Mar 10, 2024
feat: Support `ResponseSpec(..., examples=[...])` (#3068)

Allows to define custom examples for the responses via `ResponseSpec`.

The examples set this way are always generated locally, for each response:

```json
{
    "paths": {
    "/": {
        "get": {
        "responses": {
            "200": {
            "content": {
                "application/json": {
                "schema": {...},
                "examples": ...
```

Examples that go within the schema definition cannot be set by this.
Copy link

A fix for this issue has been released in v2.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This is a new feature or request Help Wanted 🆘 This is good for people to work on
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

4 participants