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

additionalProperties type restriction not supported #300

Open
vsusaya opened this issue Apr 5, 2019 · 1 comment
Open

additionalProperties type restriction not supported #300

vsusaya opened this issue Apr 5, 2019 · 1 comment

Comments

@vsusaya
Copy link

vsusaya commented Apr 5, 2019

I have the following RAML, which defines a type where I want to restrict the type of any additional properties. This is valid RAML based on the 1.0 specification. It seems that the // field is treated as having an empty string value as a name which throws an index out of bounds exception during code generation (please also see the stack trace below).

Any chance there's a known workaround?

#%RAML 1.0
title: my-raml

types:
  Items:
    type: object
    properties:
      //:
        type: string

/items:
  get:
    responses:
      200:
        body:
          application/json:
            type: Items

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.jsonschema2pojo.util.NameHelper.normalizeName(NameHelper.java:46)
at com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper.cleanNameForJava(NamingHelper.java:362)
at com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper.cleanNameForJava(NamingHelper.java:354)
at com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper.getParameterName(NamingHelper.java:342)
at com.phoenixnap.oss.ramlplugin.raml2code.interpreters.ObjectTypeInterpreter.interpret(ObjectTypeInterpreter.java:171)
at com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper.mapTypeToPojo(RamlTypeHelper.java:100)
at com.phoenixnap.oss.ramlplugin.raml2code.data.ApiActionMetadata.parseResponse(ApiActionMetadata.java:228)
at com.phoenixnap.oss.ramlplugin.raml2code.data.ApiActionMetadata.(ApiActionMetadata.java:78)
at com.phoenixnap.oss.ramlplugin.raml2code.data.ApiResourceMetadata.addApiCall(ApiResourceMetadata.java:55)
at com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlParser.checkResource(RamlParser.java:167)
at com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlParser.extractControllers(RamlParser.java:77)
at com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.generateEndpoints(SpringMvcEndpointGeneratorMojo.java:284)
at com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.execute(SpringMvcEndpointGeneratorMojo.java:527)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more

@vsusaya
Copy link
Author

vsusaya commented Apr 5, 2019

Reusing this issue for a related question - but how do I go about using additional properties? I'm noticing that when I have a RAML object type with additionalProperties set to true, it gets generated as its own class, but that class does not have a reference to a map or other structure that would allow for setting of fields that are not predefined. I have tried this with the config <includeAdditionalProperties> set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant