Class is created with name Json[0-9]{9}


#1
resourceTypes:
  - pagedResult:
      get:
        responses:
          200:
            body:
               application/json:
               schema:  |
                    {  "$schema": "http://json-schema.org/draft-03/schema",
                        "type": "object",
                        "description": "A collection of <<resourcePathName>>",
                        "properties": {
                        "total_items":  { "type": "integer", "required": true },
                        "start_index":  { "type": "integer", "required": true },
                        "end_index":    { "type": "integer", "required": true },

                         "<<resourcePathName>>":  {
                            "type": "array",
                            "items": { "$ref": "<<resourcePathName| !singularize>>"}
                         }
                   }
              }



/foo:
  type:
    pagedResult

This seems to work with the exception of the pagedResult having a strange name. Pulling it out seems to cause issues with Jsonschematopojo.

Is there a way to use to provide the name for the class?


#2

Can you elaborate a little bit more on what you try to achieve. As far as I see - this is working inside the designer and the console gives the correct output as well.


#3

The issue I am having is that the resource type is generated with a dynamic file name in the model. Something like Json1834346158 I am looking if there is a way to specify a class name using the <>.


#4

AH - are you talking about some stub generator tool?


#5

yeah, jsontopojo, or at least the implementation that comes with the RAMLjavaparser.


#6

I think the parser are not really implementing that logic. Could you please raise an issue on the appropriate github repo to let the developers know you’ve got a problem?


#7

Just in case anyone else run into this issue, I wanted to report back with the solution we found. jsonschema2pojo will do weird things with class naming when implementing resources with context driven names.

You can specify the class name by including the following in the jsonschema:

"javaType" : "com.company.app.model.<<resourcePathName|!capitalize>>Collection"

or something along those lines.


#8

That’s interesting - thanks for sharing @lenois