Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #7909
Closed
Open
Issue created Nov 09, 2020 by Administrator@rootContributor

[REQ] [rust-server] Log ApiError instead of discarding it

Created by: N-Schaef

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

As far as I understood swagger::ApiError from its description, it should be returned for non-user interfacing errors. When it is returned from the API, an internal server error is displayed to the user automatically, which I think works as intended.

But I also expected the error to be logged for the developer/administrator to investigate the problem.

Describe the solution you'd like

I think it would be good to log the error. In my local fork, I've changed

https://github.com/OpenAPITools/openapi-generator/blob/eceac6a63c3b03715f922d7c65e08a0aee2c8e0e/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache#L602-L605

to

Err(e) => {
  // Application code returned an error. This should not happen, as the implementation should
  // return a valid response.
  error!("{}",e);
  *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;

and of course added a import for log::error.

Is this in line with the expectations of the maintainers, and should I open a PR with the changes?

Or is it working as intended and ApiError should be discarded? Then I'd explain that somewhere or document this behavior.

Assignee
Assign to
Time tracking