swagger-api / swagger-api/swagger-codegen

C# ASP .NET core not producing XML payloads.

Open
#6,670 1 comment 0 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

I'm trying to implement an API that only uses XML payloads and not JSON but when generating an ASP .NET core server it only returns JSON payloads and the generated code remains the same regardless of whether I specify:

      produces:
        - application/xml

or

      produces:
        - application/json

I'm not sure if this is related to: https://github.com/swagger-api/swagger-codegen/issues/4900 where C# clients don't support XML payloads. I'd appreciate it if someone can let me know whether XML payloads are implemented for the ASP .NET core server or not.

Swagger-codegen version

2.3.0 (current master commit b22fb30)

Swagger declaration file content or url
swagger: '2.0'
info:
  title: An API
  version: 0.0.1
host: api.example.com
paths:
  /apath:
    get:
      summary: Returns an object
      produces:
        - application/xml #Switching to application/json makes no difference
      responses:
        '200':
          description: Get AnObject
          schema:
            $ref: '#/definitions/AnObject'
definitions:
  AnObject:
    type: object
    properties:
      aProperty:
        type: integer
        format: int64
Command line used for generation

./modules/swagger-codegen-cli/target/swagger-codegen-cli-2.3.0-SNAPSHOT-shaded.jar generate -i example.yml -l aspnetcore -o ./example

Steps to reproduce

Generate a ASP .NET core server with the above yaml and attempt to GET AnObject from apath. It returns a JSON payload even though it is only set to produce XML.

Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/4900

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 with the example.yml definition and the generated ASP.NET Core server from the stated swagger-codegen command. Compare generated output for application/xml and application/json, then determine whether XML response support is implemented; done means the generated server honors the declared produces media type or clearly documents the limitation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.