Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fields with $ result in error #449

Closed
queen3 opened this issue Aug 18, 2022 · 4 comments · Fixed by #457
Closed

[BUG] Fields with $ result in error #449

queen3 opened this issue Aug 18, 2022 · 4 comments · Fixed by #457
Assignees
Labels
bug Something isn't working Triage needed

Comments

@queen3
Copy link

queen3 commented Aug 18, 2022

If the field contain $ in the name, the JsonKey name is treated as a symbol and this results in an error.

So the generated code is

@jsonkey(name: '$Solution')
final String? $Solution;

and the compilation error is

Arguments of a constant creation must be constant expressions.
Undefined name 'Solution'.

I suppose $ has to be escaped somehow in the generated code.

@queen3 queen3 added bug Something isn't working Triage needed labels Aug 18, 2022
@Vovanella95
Copy link
Collaborator

hi @queen3 !

Please share part of swagger file, generated this. Thanks!

@queen3
Copy link
Author

queen3 commented Aug 19, 2022

Hello.

Yes, sorry, not sure if I can share the whole file, so here's that part:

"definitions": {
    "AffectedItem": {
        "type": "object",
        "properties": {
            "Id": {
                "format": "uuid",
                "type": "string",
                "example": "00000000-0000-0000-0000-000000000000"
            },
            "$Solution": {
                "type": "string"
            },
            "$ItemType": {
                "type": "string"
            },
            "$Created": {
                "type": "boolean"
            },
            "$Deleted": {
                "type": "boolean"
            },
            "$Hint": {
                "type": "string"
            }
        }
    },

@Vovanella95
Copy link
Collaborator

@queen3 thanks! Will fix it asap!

@davorzlotrg
Copy link

davorzlotrg commented Aug 24, 2022

I have the same issue with dots in property names (Company.Id, Company.Name)...

{
  "openapi": "3.0.1",
  "info": {
    "title": "Api",
    "version": "v1"
  },
  "paths": {
	"/api/profiles/work-info": {
      "post": {
        "tags": [
          "Profile"
        ],
        "parameters": [
          {
            "name": "LANGUAGE",
            "in": "header",
            "description": "Controls the language the API uses"
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "Company.Id": {
                    "type": "integer",
                    "format": "int32"
                  },
                  "Company.Name": {
                    "type": "string"
                  },
                  "JobTitle": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "Company.Id": {
                  "style": "form"
                },
                "Company.Name": {
                  "style": "form"
                },
                "JobTitle": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Triage needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants