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.

Only swagger generation for end-point

See original GitHub issue

Hello @apryor6 . I am happy using this library, but sometimes I want to do something before validation, for example pass context to Marshmallow Schema, but I still want to generate swagger for this API.

I’d like to contribute to the library implementing such functionality. What is the best way to do it to your opinion?

  • extend existing both accepts and responds decorators with validate: bool param.
  • create new decorator @swagger just for generation swagger spec.

What do you think?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vryazanovcommented, Jun 18, 2020

Started implementation and realized that we can pass an instance of schema to the decorator, so it’s not a problem to pass context into constructor directly. as well as many parameter. according to https://github.com/apryor6/flask_accepts/commit/c32b169e8d7099cc0a6fc85dc326160216a13185

1reaction
vryazanovcommented, Jun 13, 2020

@vladarefiev @apryor6 hey guys, I’m interesting in this topic as well. The main problem to me is that I cannot pass some extra params to Schema constructor directly, for one case I want to pass partial (but I know that it’is already implemented), for another case it could be a context. That’s deffinetly not a problem with partial parameter, but there are some problems with context, since in many cases the context should be generated in runtime, not import time (like if a part of context should be some data from request or request itself). Maybe the high-level interface could look like:

def get_context():
    return {'request': flask.request}


class Resource(...):
        @responds(schema=WidgetSchema, schema_context=get_context, api=api)
        def post(self):
            pass

and somewhere under the hood:

def get_create_schema(schema_class, schema_context):
    return schema_class(...., context=schema_context())

wdyt? let me know if I can help somehow

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Code & Client Generator | Swagger Codegen
Codegen simplifies your build process by generating server stubs and client SDKs for any API defined with the OpenAPI specification. Download Codegen today....
Read more >
Show only specific APIs on Swagger — Asp.Net Core - Medium
If we run the application and type endpoint “swagger” in the URL, we are already able to see the documentation with all the...
Read more >
Selective Generation with Swagger Codegen
When generating the stub code for the backend powering the API, it may not always be desirable to generate stubs for every endpoint...
Read more >
Hiding Endpoints From Swagger Documentation in Spring Boot
Let's have a look at how we can hide endpoints from Swagger API documentation. ... Note: We can only use @Hidden when we're...
Read more >
Configuring and Using Swagger UI in ASP.NET Core Web API
NET Core API using only the latest . ... SwaggerGen : A Swagger generator that builds SwaggerDocument objects directly from our routes, ...
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