OpenAPITools / OpenAPITools/openapi-generator

[BUG][CSHARP] Issue with '&' (ampersand) in string data

Open
#20,546 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

hi,
my customer found a problem with '&' handling in json.
after some debug, i believe the problem is in openapi generator for c#.

my server is java and in the last 2 years i never had any issue with openapi/server java.

im using the last jar, and here is how i generate my client in ant:

<java jar="**openapi-generator-cli-7.9.0.jar**"
  fork="true"
    failonerror="true"
    maxmemory="128m">
  <arg value="generate"/>
  <arg value="--skip-validate-spec"/>
  <arg value="-g"/>
  <arg value="csharp"/>	  
  <arg value="--additional-properties=targetFramework=net48"/>
  <arg value="--additional-properties=packageName=${csprj}"/>
  <arg value="--additional-properties=validatable=false"/>	  	  
  <arg value="-o"/>
  <arg value="generated"/>
  <arg value="-i"/>
  <arg value="${yaml.dir}/wsd.json"/>
</java>

here is an example of a data field ("notes")

        "S1UserInfo": {
            "type": "object",
            "properties": {
                ....
                "**notes**": {
                    "type": "string",
                    "nullable": true
                },

everything work well, except when i set the S1UserInfo.notes to "a & b". my java server (i checked using zalando's http logger) it show "a & b", as in html.
i hope somebody can help me to understand if is a bug or i missed something.

thanks,
David

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 by reproducing the report with the Ant generate command using openapi-generator-cli-7.9.0.jar, the C# generator, and the S1UserInfo.notes string value a & b. Compare the generated client's request with the server's logged payload; done means the literal ampersand is transmitted without becoming &amp;.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, java
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.