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

Consider renaming the "in" property of InputValidationIssue #9

Open
webketje opened this issue Feb 6, 2023 · 2 comments
Open

Consider renaming the "in" property of InputValidationIssue #9

webketje opened this issue Feb 6, 2023 · 2 comments

Comments

@webketje
Copy link

webketje commented Feb 6, 2023

The word in is a reserved keyword in many languages used for web programming (Python, Javascript, C#, Groovy and probably many others).
This makes it hard to access it from an object without extra safeguards:

Javascript example:

belgifError.issues[0].detail   // ok
belgifError.issues[0].in       // SyntaxError
belgifError.issues[0]['in']    // clunky, disables type checking in Typescript

Or even requires developers to add a mapping layer as in C#:

class BelgifInputValidationIssue
{
  string in = "body";  // error CS1519: Unexpected symbol `in'

  static void Main(string[] args)
  {
    BelgifInputValidationIssue instance = new BelgifInputValidationIssue();
  }
}

Possible alternative: context? location? origin? request_component?

(PS: I work for with belgif-conforming API's at BOSA but this is my personal account)

@pvdbosch
Copy link
Contributor

pvdbosch commented Feb 6, 2023

The "name" property can be used to describe the full location, like in the example in the guide : https://www.belgif.be/specification/rest/api-guide/#bad-request

   {
      "type": "urn:problem-type:belgif:input-validation:schemaViolation",
      "in": "body",
      "name": "mandator.enterpriseNumber",
      "value": "123456",
      "detail": "An enterprise number should be 10 digits long"
    }

We didn't want to mandate this, because it can be tricky to implement this correctly depending on framework used.
The in parameter name was chosen to be consistent with how it's defined in OpenAPI, but this could be weighed against language support.

@JDMKSZ
Copy link
Contributor

JDMKSZ commented Jun 21, 2023

The OpenAPI code generator handles this. Reserved keywords are prefixed by a '_'. See AbstractCSharpCodegen.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To do
Development

No branches or pull requests

3 participants