swagger-api / swagger-api/swagger-codegen

app.json_encoder is deprecated

Open
#12,198 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The Python Flask codegen uses a method that is or will be deprecated. Upon running the flask server I encounter this message:

[...]/swagger_server/__main__.py:30: DeprecationWarning: 'app.json_encoder' is deprecated and will be removed in Flask 2.3. Customize 'app.json_provider_class' or 'app.json' instead.
Swagger-codegen version

Using the latest version at the time of this writing.

Swagger declaration file content or url

Not applicable

Command line used for generation

SwaggerHub UI online

Steps to reproduce
  • Generate Python Flask code
  • Run the generated Flask server using python3 -m swagger_server from the root of the folder provided by codegen
Related issues/PRs

Couldn't find any after doing a search

Suggest a fix/enhancement

Instead of using app.json_encoder, use one of the functions selected by the message.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the generated swagger_server/main.py mentioned in the report and trace where app.json_encoder is assigned. Check the Flask guidance in the deprecation warning, then identify the corresponding Python Flask generator template in this repository. Done means newly generated servers no longer emit this warning when started with python3 -m swagger_server.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.