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

Boolean not recognized correctly when using required fields #81

Closed
rajkumar1979 opened this issue May 6, 2015 · 4 comments
Closed

Boolean not recognized correctly when using required fields #81

rajkumar1979 opened this issue May 6, 2015 · 4 comments

Comments

@rajkumar1979
Copy link

I have a raml file and am trying to generate the POJO's using 1.3.4 SNAPSHOT plugin.

The plugin works perfectly if there are no required fields, but when I add the required fields it throws the below mentioned exception

Failed to execute goal org.raml.plugins:raml-jaxrs-maven-plugin:1.3.4-SNAPSHOT:generate (default) on project webs-order-quotes-raml-jaxrs: Error generating Java classes from: /Users/rramakrishnan/spring/websworkspace/webs-order-quotes-raml-jaxrs/src/main/resources/raml/webs-subscription-signup.raml: Invalid RAML definition:
[ERROR] ERROR invalid JSON schema (preOrderQuoteRequest):
[ERROR] error: value has incorrect type (found array, expected one of [boolean])
[ERROR] level: "error"
[ERROR] domain: "syntax"
[ERROR] schema: {"loadingURI":"#","pointer":""}
[ERROR] keyword: "required"
[ERROR] found: "array"
[ERROR] expected: ["boolean"]

@rajkumar1979
Copy link
Author

The raml definition

#%RAML 0.8
title: Create Pre-order Quote API
version: v1
#baseUri: http://worldwide-order-qa.api.intuit.net/{version}
baseUri: http://mocksvc.mulesoft.com/mocks/9f89b5b2-f3f9-49f4-92ca-dded4ba86744/{version}
mediaType: application/json
schemas: 
  - preOrderQuoteRequest: |
      {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "realmID": {
                    "type": "string",
                    "description": "the company Identifier in OII (also the customerAccountID in EBP). If realmID is provided, and an address is not provided, this service will retrieve the address from OII identity service.*MDR is to give either realmID or country. If country given (or found in OII) is US or CA, then state is also mandatory."
                },
               "taxRegistration": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "additionalProperties": false,
                         "description":"",
                         "properties":{
                            "ID": {
                                     "type":"string",
                                     "description":"Customer's tax registration Id associated with their business, this is used to determine if a customer is B2B or B2C."
                                  },
                             "type": {
                                  "type":"string",
                                  "description":"Customer's tax registration ID's are classified into the following types GST,PST,QST etc."
                             }         
                         }
                    }
                },
                "address": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "the address to be used in tax calculation. address is required if realmID is not provided. If both address and realmID are provided, realmID will be ignored and address will be used for tax calculation.*MDR is to give either realmID or country. If country given (or found in OII) is US or CA, then state is also mandatory.",
                    "properties": {
                        "addressLine1": {
                            "type": "string",
                            "description": "First address line associated with the address to be used for tax calculation"
                        },
                        "addressLine2": {
                            "type": "string",
                            "description": "Optional second address line"
                        },
                        "addressLine3": {
                            "type": "string",
                            "description": "Optional third address line"
                        },
                        "addressLine4": {
                            "type": "string",
                            "description": "Optional fourth address line"
                        },
                        "city": {
                            "type": "string",
                            "description": ""
                        },
                        "stateOrProvince": {
                            "type": "string",
                            "description": "*MDR: If country given (or found in OII) is US or CA, then state is also mandatory."
                        },
                        "postalCode": {
                            "type": "string",
                            "description": ""
                        },
                        "country": {
                            "type": "string",
                            "description": "country 2 letter ISO code *MDR: country is mandatory if realmID is not provided "
                        }
                    }
                },
                "transactionLine": {
                    "type": "array",
                    "items": 
                        {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "offerID": {
                                    "type": "integer",
                                    "description": "the offerID which the customer is buying, opting-in, upgrading, or re-subscribing"
                                },
                                "subscriptionID": {
                                    "type": "integer",
                                    "description": "identifies the customer's current subscription, so that any pro-ration, or credit, may be accounted for in the quote."
                                }
                            }
                        }

                }
            },"required":["realmID"]
      }
  - preOrderQuoteResponse: |
       {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "quoteAmount": {
                    "description": "Total Amount of the quote including full charges, pro-rated charges and sales tax to be collected up front",
                    "type": "integer"
                },
                "taxDetails": {
                    "description": "Total amount of sales tax that applies to the up front charges. This is included in quoteAmount",
                    "type": "array",
                    "additionalProperties": false,
                    "items": {
                        "type": "object",
                        "properties": {
                            "taxType": {
                                "description": "GST,PST,QST",
                                "type": "string"
                            },
                            "taxRate": {
                                "description": "Tax rate associated with the tax type.",
                                "type": "string"
                            },
                            "taxAmount": {
                                "description": "Tax amount associated with the tax type.",
                                "type": "string"
                            }
                        }
                    }
                },
                "quoteEffectiveDate": {
                    "description": "Effective Date for the future dates quote.",
                    "type": "string"
                },
                "currency": {
                    "description": "Currency Associated with the charge details",
                    "type": "string"
                },
                "chargeDetails": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "offeringType": {
                                "description": "Provides breakdown of quote by offering.",
                                "type": "string"
                            },
                            "chargeType": {
                                "description": "Recurring, One-Time",
                                "type": "string"
                            },
                            "chargeDescription": {
                                "description": "Example: QBO setup fee, QBO recurring charge, QBO recurring pro-rated credit, QBO recurring pro-rated debit",
                                "type": "string"
                            },
                            "rateUsed": {
                                "description": "For One-time fees, it is the same as the amount. For Recurring, it is the recurring amount to be billed; in case of pro-rated charges, the rate used & the amount will be different as the amount will show the pro-ration.",
                                "type": "integer"
                            },
                            "amount": {
                                "description": "For One-time fees, it is the same as the rateUsed. For Recurring fees, if no proration, this amount would be the same as the rateUsed. In case of pro-ration, it would show the pro-rated amount to be paid now.",
                                "type": "integer"
                            },
                            "discountDetails": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "discountID": {
                                            "description": "Unique discount id.",
                                            "type": "string"
                                        },
                                        "description": {
                                            "description": "E.g. 40% off discount",
                                            "type": "string"
                                        },
                                        "startDate": {
                                            "description": "Start of the discount period",
                                            "type": "integer"
                                        },
                                        "endDate": {
                                            "description": "End of the discount period",
                                            "type": "integer"
                                        },
                                        "discountType": {
                                            "description": "E.g. Percent or Amount",
                                            "type": "string"
                                        },
                                        "discountValue": {
                                            "description": "E.g. 40",
                                            "type": "integer"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
       }
/quotes:
  displayName: quote
  post:
    headers:
      Accept:
        description:
          desc -- do we really need this to be required
          throw error if not provided, or unsupported media type
        type: string
        required: true
        example: example

      Authorization:
        description:
          desc
          throw error if not provided
        type: string
        required: true
        example: Intuit_IAM_Authentication intuit_token_type="IAM-Ticket",intuit_realmid="50000003",intuit_appid="Intuit.cto.api.gateway.simulator.test",intuit_token="V1-65-Q3y8elbiw74j5wdna2cei5",intuit_userid="100186433"

      Content-Type:
        description:
          here is the description
          throw error if not provided
        type: string
        required: true
        example: application/json; charset=utf-8

      User-Agent:
        description:
          des
        type: string
        required: false
        example: curl/7.30.0

      intuit_originatingip:
        description: des
          throw error if not provided
        type: string
        required: true
        example: 100.100.10.1

      intuit_webs_transaction_datetime:
        description: des
          in prod, set to current date time
          in pre-prod and the time-based testing flag is set to true, propagate date time if passed in, otherwise set to current date time
          in pre-prod with time-based testing flag set to false, set to current date time
        type: string
        required: false
        example: sss

      intuit_locale:
        description: 
          Here is the description for the header. 
          throw error if not provided
        type: string 
        required: true
        minLength: 5
        maxLength: 5
        example: en_US

      intuit_tid:
        description:
          desc
          throw error if not provided
        type: string
        required: true
        example: gw-7f501242-b7ab-43e7-a862-93027855347f

      intuit_assetalias:
        description: desc
          throw error if not provided
        type:  string
        required: true
        example: Intuit.cto.gateway-fabric.8

      intuit_assetid:
        description: desc
          throw error if not provided
        type: integer
        required: true
        example: 5189290262823711479
    description: The Create Pre-order Quote API returns offer promised price inclusive of taxes, proration, discounts and refunds (if applicable).  Can be called from marketing context (non-authenticated) and in-product (authenticated)
    body: 
      schema: preOrderQuoteRequest
      example : | 
                 {"realmID":"123145630520667","transactionLines":[{"offerID":20000013}]}
    responses:             
     200:
      body:
       schema: preOrderQuoteResponse  
       example : |               
                   { 
                       "quoteAmount": 96, 
                       "taxAmount": 0, 
                       "quoteEffectiveDate": null, 
                        "chargeDetails": [ 
                           { 
                             "offeringType": "QBO", 
                              "chargeType": "Recurring", 
                              "chargeDescription": "QBO Recurring", 
                              "rateUsed": 120, 
                              "amount": 120, 
                              "discountDetails": [] 
                            }, 
                            { 
                              "offeringType": "QBO", 
                               "chargeType": "Discount", 
                               "chargeDescription": "QBO Discount", 
                               "rateUsed": -24, 
                               "amount": -24, 
                               "discountDetails": [{ 
                                 "discountID": "24000002", 
                                 "description": "QuickBooks Online 20 Percent Discount", 
                                 "startDate": 1429167600000, 
                                 "endDate": 1460790000000, 
                                  "discountType": "P", 
                                  "discountValue": 20 
                                       }] 
                                    } 
                                 ] 
                   } 

@ddossot
Copy link

ddossot commented May 6, 2015

The reported issue is not related to a Boolean not recognized but to the handling of JSON Schema draft-4 style of required property:

"required": [
    "realmID"
]

Instead of "required": true in draft-3.

Try adding:

"$schema": "http://json-schema.org/draft-04/schema#"

to your schemas to see if it switches the JSON parser to draft-4.

@petrochenko-pavel-a
Copy link
Contributor

Thanks a lot David. And yep adding $schema should work. Please let me know if it does not works for you.

Regards,
Pavel

@rajkumar1979
Copy link
Author

Thanks a lot guys, by default it looks for draft 3 I guess...
It works now with the schema definition pointing to draft4 in the URI.

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

No branches or pull requests

3 participants