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

Examples in request and response #115

Closed
Niccolum opened this issue Jul 8, 2020 · 3 comments
Closed

Examples in request and response #115

Niccolum opened this issue Jul 8, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@Niccolum
Copy link

Niccolum commented Jul 8, 2020

Is it possible to pass example in request or response in APIView to create example request with swagger and see examle response?

@tfranzel
Copy link
Owner

tfranzel commented Jul 8, 2020

that is currently not supported. would be a nice feature addition though. it would probably be another parameter to @extend_schema

@tfranzel tfranzel added the enhancement New feature or request label Jul 8, 2020
@KimSoungRyoul
Copy link
Contributor

KimSoungRyoul commented Oct 24, 2020

@tfranzel

how about these code to support example feature?

@extend_schema_serializer(
 examples=[
          OpenApiExample( 'ex1',
                  summary='i_am_summary',
                  description='long description...'
                  value={
                       'username':'i_am_user1',
                       'password':'1234'
                    }
          ),
          OpenApiExample('ex2',
               ....
          ),
 ],
  exclude_fields = ("date_joined",)
)
class UserSerializer(serializer.ModelSerializer):
     
   class Meta:
        model = User
        fields = ("username","passwod", "date_joined")

and this is in my thought to support Swagger Components <-> DRF Components

@extend_schema_parameter(
   # something to customize.  
)
class UserFilterSet(filters.FilterSet):
     
    class Meta:
         model = User
         fields =. ("username","email") 

@tfranzel
Copy link
Owner

feature was added via #208 and #231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants