0

I'm doing code generation with the open api generator tool to generate a typescript-axios client, but unfortunately there's a couple of issues I'm running into.

  1. There is a property in the open api doc we're generating from called long. However, the interface it generates changes that property to _long which is not correct. I can't find anywhere in the mustache template that is doing this so it must be happening in the CLI layer. Can this behavior be prevented?

Swagger property definition:

"long": {
  "type": "number",
  "description": "The longitude location.",
  "format": "double",
  "nullable": true
}

Codegen interface property output:

/**
 * The longitude location.
 * @type {number}
 * @memberof ...
 */
_long?: number | null;
  1. Dates are passed as strings to the API and are defined as such in the open api doc, but it seems when they have a date-time format, the interface says it requires a Date object. This is not ideal in our situation, but again this appears to happen at the CLI level so I can't prevent this behavior by modifying the mustache template.

Swagger property definition:

"startDate": {
  "type": "string",
  "description": "Gets or sets the start date of the search date range.",
  "format": "date-time",
  "nullable": true
},

Codegen interface property output:

/**
 * Gets or sets the start date of the search date range.
 * @type {Date}
 * @memberof ...
 */
startDate?: Date | null;

Thanks in advance for any help!

1

1 Answer 1

1

You can pass a type-mappings to the CLI:

java -jar openapi-generator-4.2.3.jar generate --type-mappings DateTime=string etc..

This will turn the type Date into a string. Problem is that it doesn't matter if you define a date or a date-time in your schema definition. You will get only string now.

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

Comments

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.