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
  • #9334
Closed
Open
Issue created Apr 24, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][dart-dio-next] Generator uses url encoded contentType even if the server content type requires application/json

Created by: themisir

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I'm using Asp.Net Core Swashbuckle to generate openapi scheme for my backend. The backend supports multiple content-type variants of application/json. But generated code uses url encoded content type instead of application/json.

Here's generated code output which picks first match which is "application/json-patch+json".

contentType: [
  'application/json-patch+json',
  'application/json',
  'text/json',
  'application/_*+json',
].first

But then Did checks if content-type is application/json then uses json encoding but if it isn't, it uses url encoding and my server returns HTTP 415 Unsupported Media Type status.

openapi-generator version

5.1.0

OpenAPI declaration file content or url

The OpenAPI declaration that caused this issue was used for private api. So I couldn't share it here.

Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
  1. Overriding content-type header using command line options provided to generator CLI
  2. Updating contentType matching part to choose most suitable match rather than first one
Assignee
Assign to
Time tracking