pattern annotation doesn't generate on int64 swagger using open api generator

Solution 1:

The pattern keyword lets you define a regular expression template for the string value

It does not support Integer/Long


https://swagger.io/docs/specification/data-models/data-types/#pattern

The documentation states:

The pattern keyword lets you define a regular expression template for the string value. Only the values that match this template will be accepted. The regular expression syntax used is from JavaScript (more specifically, ECMA 262). Regular expressions are case-sensitive, that is, [a-z] and [A-Z] are different expressions. For example, the following pattern matches a Social Security Number (SSN) in the 123-45-6789 format:

ssn:
  type: string
  pattern: '^\d{3}-\d{2}-\d{4}$'

Note that the regular expression is enclosed in the ^…$ tokens, where ^ means the beginning of the string, and $ means the end of the string. Without ^…$, pattern works as a partial match, that is, matches any string that contains the specified regular expression. For example, pattern: pet matches pet, petstore and carpet. The ^…$ token forces an exact match.

For the datatype integer, it will look like:

    type: integer
    format: int64
    minimum: -86400
    maximum: 86400

To clarify minimum/maximum:

Minimum and Maximum Use the minimum and maximum keywords to specify the range of possible values:

type: integer
minimum: 1
maximum: 20

By default, the minimum and maximum values are included in the range, that is:

minimum ≤ value ≤ maximum

To exclude the boundary values, specify exclusiveMinimum: true and exclusiveMaximum: true. For example, you can define a floating-point number range as 0–50 and exclude the 0 value:

type: number
minimum: 0
exclusiveMinimum: true
maximum: 50

The word “exclusive” in exclusiveMinimum and exclusiveMaximum means the corresponding boundary is excluded: Keyword Description exclusiveMinimum: false or not included value ≥ minimum exclusiveMinimum: true value > minimum exclusiveMaximum: false or not included value ≤ maximum exclusiveMaximum: true value < maximum