Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Add possibility to generate uriParameters as longs #328

Closed
LumnitzF opened this issue Jan 18, 2018 · 4 comments
Closed

Add possibility to generate uriParameters as longs #328

LumnitzF opened this issue Jan 18, 2018 · 4 comments
Projects

Comments

@LumnitzF
Copy link

When having an uriParameter with type "integer" it is generated as "int". Please add the possibility to generate it as "long"

@jpbelang
Copy link
Contributor

Yup. it should be possible with the new object generator. Will post an answer on the weekend.

@jpbelang
Copy link
Contributor

Sorry for the delay: on release/2.2.0.

This can be done with the changeType plugin. Without the unbox parameter, you keep the java.lang.Long:

#%RAML 1.0
title: Hello World API
version: v1
baseUri: https://api.github.com
mediaType: application/json
uses:
  ramltopojo: ramltopojo.raml
/search:
    description: The search resource
    uriParameters:
        id:
            type: integer
            (ramltopojo.types):
              plugins:
                - name: core.changeType
                  arguments: [ java.lang.Long, unbox ]
    get:
        body:
            text/plain:
                type: string
        responses:
            200:
                body:
                    application/json:
                        type: string

The contents of ramltopojo.raml is

annotationTypes:
    types:
        allowedTargets: [TypeDeclaration,API]
        properties:
            className?:
                type: string
            implementationClassName?:
                type: string
            usePrimitiveType?:
                type: boolean
            abstract?:
                type: boolean
            plugins?: any[]

@LumnitzF
Copy link
Author

Thank you! To be honest, I've expected something like the "useLongIntegers" option in jsonschema2pojo, but this will also work.

@jpbelang
Copy link
Contributor

Just FYI:
There is a format facet to integer and number in raml. You can also use this. Maybe that's better. I implemented them just now. :-)

types:
  RamlDataType:
    type: object
    properties:
      propNumber:
        type: number
        format: int32

As to using options, raml annotations allow for finer grained control. I really prefer these :-)

@jpbelang jpbelang added this to Done in 3.0.0 Jan 29, 2018
@jstoiko jstoiko closed this as completed Mar 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
3.0.0
  
Done
Development

No branches or pull requests

3 participants