Better handling of backtick in pattern (#19358)

* use x-go-datatag in go client model template

* add logic to handle backtick
This commit is contained in:
William Cheng
2024-08-16 18:04:47 +08:00
committed by GitHub
parent cd02426648
commit a6a75e3501
6 changed files with 107 additions and 1 deletions

View File

@@ -1683,6 +1683,10 @@ components:
to three digits following i.e. Image_01.
pattern: "/^image_\\d{1,3}$/i"
type: string
pattern_with_backtick:
pattern: "^$|^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\
.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
type: string
required:
- byte
- date

View File

@@ -19,6 +19,7 @@ Name | Type | Description | Notes
**Password** | **string** | |
**PatternWithDigits** | Pointer to **string** | A string that is a 10 digit number. Can have leading zeros. | [optional]
**PatternWithDigitsAndDelimiter** | Pointer to **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
**PatternWithBacktick** | Pointer to **string** | | [optional]
## Methods
@@ -394,6 +395,31 @@ SetPatternWithDigitsAndDelimiter sets PatternWithDigitsAndDelimiter field to giv
HasPatternWithDigitsAndDelimiter returns a boolean if a field has been set.
### GetPatternWithBacktick
`func (o *FormatTest) GetPatternWithBacktick() string`
GetPatternWithBacktick returns the PatternWithBacktick field if non-nil, zero value otherwise.
### GetPatternWithBacktickOk
`func (o *FormatTest) GetPatternWithBacktickOk() (*string, bool)`
GetPatternWithBacktickOk returns a tuple with the PatternWithBacktick field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.
### SetPatternWithBacktick
`func (o *FormatTest) SetPatternWithBacktick(v string)`
SetPatternWithBacktick sets PatternWithBacktick field to given value.
### HasPatternWithBacktick
`func (o *FormatTest) HasPatternWithBacktick() bool`
HasPatternWithBacktick returns a boolean if a field has been set.
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -39,6 +39,7 @@ type FormatTest struct {
PatternWithDigits *string `json:"pattern_with_digits,omitempty" validate:"regexp=^\\\\d{10}$"`
// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
PatternWithDigitsAndDelimiter *string `json:"pattern_with_digits_and_delimiter,omitempty" validate:"regexp=^image_\\\\d{1,3}$/i"`
PatternWithBacktick *string "json:\"pattern_with_backtick,omitempty\" validate:\"regexp=^$|^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$\""
AdditionalProperties map[string]interface{}
}
@@ -517,6 +518,38 @@ func (o *FormatTest) SetPatternWithDigitsAndDelimiter(v string) {
o.PatternWithDigitsAndDelimiter = &v
}
// GetPatternWithBacktick returns the PatternWithBacktick field value if set, zero value otherwise.
func (o *FormatTest) GetPatternWithBacktick() string {
if o == nil || IsNil(o.PatternWithBacktick) {
var ret string
return ret
}
return *o.PatternWithBacktick
}
// GetPatternWithBacktickOk returns a tuple with the PatternWithBacktick field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FormatTest) GetPatternWithBacktickOk() (*string, bool) {
if o == nil || IsNil(o.PatternWithBacktick) {
return nil, false
}
return o.PatternWithBacktick, true
}
// HasPatternWithBacktick returns a boolean if a field has been set.
func (o *FormatTest) HasPatternWithBacktick() bool {
if o != nil && !IsNil(o.PatternWithBacktick) {
return true
}
return false
}
// SetPatternWithBacktick gets a reference to the given string and assigns it to the PatternWithBacktick field.
func (o *FormatTest) SetPatternWithBacktick(v string) {
o.PatternWithBacktick = &v
}
func (o FormatTest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
@@ -564,6 +597,9 @@ func (o FormatTest) ToMap() (map[string]interface{}, error) {
if !IsNil(o.PatternWithDigitsAndDelimiter) {
toSerialize["pattern_with_digits_and_delimiter"] = o.PatternWithDigitsAndDelimiter
}
if !IsNil(o.PatternWithBacktick) {
toSerialize["pattern_with_backtick"] = o.PatternWithBacktick
}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
@@ -642,6 +678,7 @@ func (o *FormatTest) UnmarshalJSON(data []byte) (err error) {
delete(additionalProperties, "password")
delete(additionalProperties, "pattern_with_digits")
delete(additionalProperties, "pattern_with_digits_and_delimiter")
delete(additionalProperties, "pattern_with_backtick")
o.AdditionalProperties = additionalProperties
}