0

Some help needed i was trying to generate the swagger client code using the command for an Expedia mobile API

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://www.expedia.co.jp/static/mobile/swaggerui/swagger.json -l java -o samples/client/expedia

The code generation fails with the following error

[main] ERROR io.swagger.codegen.languages.JavaClientCodegen - No Type defined for Property null Exception in thread "main" java.lang.RuntimeException: Could not generate model 'detailedRentalFare'

The type attribute within the DetailedRentalFare is where it fails. I am not sure why this fails since the data type is defined. I am newbie to Swagger any help will be greatly appreciated

1

2 Answers 2

1

From @wing328's answer, even if this isn't your service to fix, you can still generate a client from it.

First, just download the JSON locally:
wget https://www.expedia.co.jp/static/mobile/swaggerui/swagger.json > expedia.json

Next, modify the value in the JSON that @wing328 pointed out

Finally, rerun your codegen using the static file as the source:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
   -i ./expedia.json \
   -l java \
   -o samples/client/expedia

It's always nice to let the service owner know about the issue, too, since fixing it will help with their adoption of the api.

Sign up to request clarification or add additional context in comments.

Comments

0

Answer provided by @wing328

the issue is caused by incorrect type for array, e.g.

"detailedRentalFare": {
  "properties": {
    "rateTerm": {
      "type": "string",
      "description": "It can have the following values: HOURLY, DAILY, WEEKLY, WEEKEND, MONTHLY, TOTAL, TRIP"
    },
    "rate": {
      "$ref": "mobilePrice"
    },
    "priceBreakdownOfTotalDueToday": {
      "type": "array",
      "items": {
        "type": "rentalFareBreakdownItem"
      }
    },

It should be

     "items": {
        "$ref": "rentalFareBreakdownItem"
      }

or even better

      "items": {
        "type": "object",
        "$ref": "rentalFareBreakdownItem"
      }

After correcting this i was able to generate the code.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.