|
| 1 | +# Testing and Purpose |
| 2 | + |
| 3 | +This client doesn't require a server to work. It only tests the regex feature. This comamnd should immediately run it: |
| 4 | + |
| 5 | +```bash |
| 6 | +go mod tidy && go vet ./... && go test ./... -v |
| 7 | +``` |
| 8 | + |
| 9 | +It is intended to test the [issue 20079 : [BUG] Golang pattern validation with regex fails on comma](https://github.com/OpenAPITools/openapi-generator/issues/20079) |
| 10 | +that is currently unsolved, for these reasons: |
| 11 | + |
| 12 | +1. For `javaComments` test case, when it should use the `^/\*.*\*/|//[^\\n]*$` pattern, the `org.yaml.snakeyaml.scanner parser` that scans the spec file, wrongly tells that `\*` is an invalid escape code. |
| 13 | + But attempting to enter `^/\\*.*\\*/|//[^\\n]*$` keeps the `\\*` and generates `^/\\*.*\\*/|//[^\n]*$` instead of the wished `^/\*.*\*/|//[^\n]*$` |
| 14 | + |
| 15 | +2. For `windowsAbsolutePath` test case, Go `validator.package v2` doesn't look handling this regexp well, and tell it having a bad parameter. |
| 16 | + |
| 17 | +## Details |
| 18 | + |
| 19 | +It tests the following regex adaptations for Golang generation: |
| 20 | + |
| 21 | +```yaml |
| 22 | +code: |
| 23 | + type: string |
| 24 | + pattern: "^[0-9]{2,}$" |
| 25 | + |
| 26 | +creditCard: |
| 27 | + description: "Visa credit card\n |
| 28 | + matches: 4123 6453 2222 1746\n |
| 29 | + non-matches: 3124 5675 4400 4567, 4123-6453-2222-1746" |
| 30 | + type: string |
| 31 | + |
| 32 | + pattern: "^4[0-9]{3}\\s[0-9]{4}\\s[0-9]{4}\\s[0-9]{4}$" |
| 33 | + # Original was: 4[0-9]{3}\s[0-9]{4}\s[0-9]{4}\s[0-9]{4} |
| 34 | + |
| 35 | +date: |
| 36 | + description: "Some dates\n |
| 37 | + matches: 31/04/1999, 15/12/4567\n |
| 38 | + non-matches: 31/4/1999, 31/4/99, 1999/04/19, 42/67/25456" |
| 39 | + type: string |
| 40 | + pattern: "^([0-2][0-9]|30|31)/(0[1-9]|1[0-2])/[0-9]{4}$" |
| 41 | + # Original was: ([0-2][0-9]|30|31)/(0[1-9]|1[0-2])/[0-9]{4} : unchanged |
| 42 | + |
| 43 | +windowsAbsolutePath: |
| 44 | + description: "Windows absolute path\n |
| 45 | + matches: \\\\server\\share\\file\n |
| 46 | + non-matches: \\directory\\directory2, /directory2" |
| 47 | + type: string |
| 48 | + |
| 49 | + # This test case doesn't work due to a problem (?) in validator.v2 (?) |
| 50 | + # it issues an unexpected unknown tag or Bad Parameter. |
| 51 | + |
| 52 | + # pattern: "^([A-Za-z]:|\\)\\[[:alnum:][:whitespace:]!\"#$%&'()+,-.;=@[]^_`{}~.]*$" |
| 53 | + # Original was: ([A-Za-z]:|\\)\\[[:alnum:][:whitespace:]!"#$%&'()+,-.\\;=@\[\]^_`{}~.]* |
| 54 | + |
| 55 | +email1: |
| 56 | + description: "Email Address 1\n |
| 57 | + matches: abc.123@def456.com, _123@abc.ca\n |
| 58 | + non-matches: abc@dummy, ab*cd@efg.hijkl" |
| 59 | + type: string |
| 60 | + |
| 61 | + pattern: "^[[:word:]\\-.]+@[[:word:]\\-.]+\\.[[:alpha:]]{2,3}$" |
| 62 | + # Original was: [[:word:]\-.]+@[[:word:]\-.]+\.[[:alpha:]]{2,3} |
| 63 | + |
| 64 | +email2: |
| 65 | + description: "Email Address 2\n |
| 66 | + matches: *@qrstuv@wxyz.12345.com, __1234^%@@abc.def.ghijkl\n |
| 67 | + non-matches: abc.123.*&ca, ^%abcdefg123" |
| 68 | + type: string |
| 69 | + |
| 70 | + pattern: "^.+@.+\\..+$" |
| 71 | + # Original was: .+@.+\..+ |
| 72 | + |
| 73 | +htmlHexadecimalColorCode1: |
| 74 | + description: "HTML Hexadecimal Color Code 1\n |
| 75 | + matches: AB1234, CCCCCC, 12AF3B\n |
| 76 | + non-matches: 123G45, 12-44-CC" |
| 77 | + type: string |
| 78 | + pattern: "^[A-F0-9]{6}$" |
| 79 | + # Original was: [A-F0-9]{6} : unchanged |
| 80 | + |
| 81 | +htmlHexadecimalColorCode2: |
| 82 | + description: "HTML Hexadecimal Color Code 2\n |
| 83 | + matches: AB 11 00, CC 12 D3\n |
| 84 | + non-matches: SS AB CD, AA BB CC DD, 1223AB" |
| 85 | + type: string |
| 86 | + |
| 87 | + pattern: "^[A-F0-9]{2}\\s[A-F0-9]{2}\\s[A-F0-9]{2}$" |
| 88 | + # Original was: [A-F0-9]{2}\s[A-F0-9]{2}\s[A-F0-9]{2} |
| 89 | + |
| 90 | +ipAddress: |
| 91 | + description: "IP Address\n |
| 92 | + matches: 10.25.101.216\n |
| 93 | + non-matches: 0.0.0, 256.89.457.02" |
| 94 | + type: string |
| 95 | + |
| 96 | + pattern: "^((2(5[0-5]|[0-4][0-9])|1([0-9][0-9])|([1-9][0-9])|[0-9])\\.){3}(2(5[0-5]|[0-4][0-9])|1([0-9][0-9])|([1-9][0-9])|[0-9])$" |
| 97 | + # Original was: ((2(5[0-5]|[0-4][0-9])|1([0-9][0-9])|([1-9][0-9])|[0-9])\.){3}(2(5[0-5]|[0-4][0-9])|1([0-9][0-9])|([1-9][0-9])|[0-9]) |
| 98 | + |
| 99 | +javaComments: |
| 100 | + description: "Java Comments\n |
| 101 | + matches: Matches Java comments that are between /* and */, or one line comments prefaced by //\n |
| 102 | + non-matches: a=1" |
| 103 | + type: string |
| 104 | + |
| 105 | + # This test case doesn't work due to a problem (?) in validator.v2 (?) |
| 106 | + # org.yaml.snakeyaml.scanner declares \* being an invalid escape code at yaml checking step |
| 107 | + |
| 108 | + # pattern: "^/\*.*\*/|//[^\\n]*$" |
| 109 | + # Original was: /\*.*\*/|//[^\n]* |
| 110 | + |
| 111 | +money: |
| 112 | + description: "\n |
| 113 | + matches: $1.00, -$97.65 |
| 114 | + non-matches: $1, 1.00$, $-75.17" |
| 115 | + type: string |
| 116 | + |
| 117 | + pattern: "^(\\+|-)?\\$[0-9]*\\.[0-9]{2}$" |
| 118 | + # Original was: (\+|-)?\$[0-9]*\.[0-9]{2} |
| 119 | + |
| 120 | +positiveNegativeDecimalValue: |
| 121 | + description: "Positive, negative numbers, and decimal values\n |
| 122 | + matches: +41, -412, 2, 7968412, 41, +41.1, -3.141592653 |
| 123 | + non-matches: ++41, 41.1.19, -+97.14" |
| 124 | + type: string |
| 125 | + |
| 126 | + pattern: "^(\\+|-)?[0-9]+(\\.[0-9]+)?$" |
| 127 | + # Original was: (\+|-)?[0-9]+(\.[0-9]+)? |
| 128 | + |
| 129 | +password1: |
| 130 | + description: "Passwords 1\n |
| 131 | + matches: abcd, 1234, A1b2C3d4, 1a2B3\n |
| 132 | + non-matches: abc, *ab12, abcdefghijkl" |
| 133 | + type: string |
| 134 | + pattern: "^[[:alnum:]]{4,10}$" |
| 135 | + # Original was: [[:alnum:]]{4,10} : unchanged |
| 136 | + |
| 137 | +password2: |
| 138 | + description: "Passwords 2\n |
| 139 | + matches: AB_cd, A1_b2c3, a123_\n |
| 140 | + non-matches: *&^g, abc, 1bcd" |
| 141 | + type: string |
| 142 | + |
| 143 | + pattern: "^[a-zA-Z]\\w{3,7}$" |
| 144 | + # Original was: [a-zA-Z]\w{3,7} : unchanged |
| 145 | + |
| 146 | +phoneNumber: |
| 147 | + description: "Phone Numbers\n |
| 148 | + matches: 519-883-6898, 519 888 6898\n |
| 149 | + non-matches: 888 6898, 5198886898, 519 883-6898" |
| 150 | + type: string |
| 151 | + |
| 152 | + pattern: "^([2-9][0-9]{2}-[2-9][0-9]{2}-[0-9]{4})|([2-9][0-9]{2}\\s[2-9][0-9]{2}\\s[0-9]{4})$" |
| 153 | + # Original was: ([2-9][0-9]{2}-[2-9][0-9]{2}-[0-9]{4})|([2-9][0-9]{2}\s[2-9][0-9]{2}\s[0-9]{4}) |
| 154 | + |
| 155 | +sentence1: |
| 156 | + description: "Sentences 1\n |
| 157 | + matches: Hello, how are you?\n |
| 158 | + non-matches: i am fine" |
| 159 | + type: string |
| 160 | + |
| 161 | + pattern: "^[A-Z0-9].*(\\.|\\?|!)$" |
| 162 | + # Original was: [A-Z0-9].*(\.|\?|!) |
| 163 | + |
| 164 | +sentence2: |
| 165 | + description: "Sentences 2\n |
| 166 | + matches: Hello, how are you?n |
| 167 | + non-matches: i am fine" |
| 168 | + type: string |
| 169 | + pattern: "^[[:upper:]0-9].*[.?!]$" |
| 170 | + # Original was: [[:upper:]0-9].*[.?!] : unchanged |
| 171 | + |
| 172 | +socialSecurityNumber: |
| 173 | + description: "Social Security Number\n |
| 174 | + matches: 123-45-6789\n |
| 175 | + non-matches: 123 45 6789, 123456789, 1234-56-7891" |
| 176 | + type: string |
| 177 | + pattern: "^[0-9]{3}-[0-9]{2}-[0-9]{4}$" |
| 178 | + # Original was: [0-9]{3}-[0-9]{2}-[0-9]{4} : unchanged |
| 179 | + |
| 180 | +url: |
| 181 | + description: "URL\n |
| 182 | + matches: http://www.sample.com, www.sample.com\n |
| 183 | + non-matches: http://sample.com, http://www.sample.comm" |
| 184 | + type: string |
| 185 | + |
| 186 | + # \. ==> \\. |
| 187 | + pattern: "^(http://)?www\\.[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}$" |
| 188 | + # Original was: (http://)?www\.[a-zA-Z0-9]+\.[a-zA-Z]{2,3} |
| 189 | +``` |
| 190 | + |
| 191 | +# Go API client for openapi |
| 192 | + |
| 193 | +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) |
| 194 | + |
| 195 | +## Overview |
| 196 | +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. |
| 197 | + |
| 198 | +- API version: 1.0 |
| 199 | +- Package version: 1.0.0 |
| 200 | +- Generator version: 7.21.0-SNAPSHOT |
| 201 | +- Build package: org.openapitools.codegen.languages.GoClientCodegen |
| 202 | + |
| 203 | +## Installation |
| 204 | + |
| 205 | +Install the following dependencies: |
| 206 | + |
| 207 | +```sh |
| 208 | +go get github.com/stretchr/testify/assert |
| 209 | +go get golang.org/x/net/context |
| 210 | +``` |
| 211 | + |
| 212 | +Put the package under your project folder and add the following in import: |
| 213 | + |
| 214 | +```go |
| 215 | +import openapi "github.com/GIT_USER_ID/GIT_REPO_ID" |
| 216 | +``` |
| 217 | + |
| 218 | +To use a proxy, set the environment variable `HTTP_PROXY`: |
| 219 | + |
| 220 | +```go |
| 221 | +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") |
| 222 | +``` |
| 223 | + |
| 224 | +## Configuration of Server URL |
| 225 | + |
| 226 | +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. |
| 227 | + |
| 228 | +### Select Server Configuration |
| 229 | + |
| 230 | +For using other server than the one defined on index 0 set context value `openapi.ContextServerIndex` of type `int`. |
| 231 | + |
| 232 | +```go |
| 233 | +ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1) |
| 234 | +``` |
| 235 | + |
| 236 | +### Templated Server URL |
| 237 | + |
| 238 | +Templated server URL is formatted using default variables from configuration or from context value `openapi.ContextServerVariables` of type `map[string]string`. |
| 239 | + |
| 240 | +```go |
| 241 | +ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{ |
| 242 | + "basePath": "v2", |
| 243 | +}) |
| 244 | +``` |
| 245 | + |
| 246 | +Note, enum values are always validated and all unused variables are silently ignored. |
| 247 | + |
| 248 | +### URLs Configuration per Operation |
| 249 | + |
| 250 | +Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. |
| 251 | +An operation is uniquely identified by `"{classname}Service.{nickname}"` string. |
| 252 | +Similar rules for overriding default operation server index and variables applies by using `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps. |
| 253 | + |
| 254 | +```go |
| 255 | +ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{ |
| 256 | + "{classname}Service.{nickname}": 2, |
| 257 | +}) |
| 258 | +ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{ |
| 259 | + "{classname}Service.{nickname}": { |
| 260 | + "port": "8443", |
| 261 | + }, |
| 262 | +}) |
| 263 | +``` |
| 264 | + |
| 265 | +## Documentation for API Endpoints |
| 266 | + |
| 267 | +All URIs are relative to *http://localhost* |
| 268 | + |
| 269 | +Class | Method | HTTP request | Description |
| 270 | +------------ | ------------- | ------------- | ------------- |
| 271 | +*DefaultAPI* | [**FooGet**](docs/DefaultAPI.md#fooget) | **Get** /foo | |
| 272 | + |
| 273 | + |
| 274 | +## Documentation For Models |
| 275 | + |
| 276 | + - [FooGet200Response](docs/FooGet200Response.md) |
| 277 | + - [ImportCode](docs/ImportCode.md) |
| 278 | + |
| 279 | + |
| 280 | +## Documentation For Authorization |
| 281 | + |
| 282 | +Endpoints do not require authorization. |
| 283 | + |
| 284 | + |
| 285 | +## Documentation for Utility Methods |
| 286 | + |
| 287 | +Due to the fact that model structure members are all pointers, this package contains |
| 288 | +a number of utility functions to easily obtain pointers to values of basic types. |
| 289 | +Each of these functions takes a value of the given basic type and returns a pointer to it: |
| 290 | + |
| 291 | +* `PtrBool` |
| 292 | +* `PtrInt` |
| 293 | +* `PtrInt32` |
| 294 | +* `PtrInt64` |
| 295 | +* `PtrFloat` |
| 296 | +* `PtrFloat32` |
| 297 | +* `PtrFloat64` |
| 298 | +* `PtrString` |
| 299 | +* `PtrTime` |
| 300 | + |
| 301 | +## Author |
| 302 | + |
| 303 | + |
| 304 | + |
0 commit comments