forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG][GO] Add support for all +json and +xml suffixed media types (Op…
…enAPITools#16816) * Add support for all +json and +xml suffixed media types to generated Go client * Export JsonCheck and XmlCheck and add external tests * Remove client_test.mustache
- Loading branch information
Showing
6 changed files
with
92 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
sw "go-petstore" | ||
) | ||
|
||
type testCase struct { | ||
String string | ||
ShouldMatch bool | ||
} | ||
|
||
func TestJsonCheck(t *testing.T) { | ||
testCases := []testCase{ | ||
{"application/json", true}, | ||
{"application/vnd.org.application+json", true}, | ||
{"application/hal+json", true}, | ||
{"text/json", true}, | ||
{"text/vnd.org.application+json", true}, | ||
{"text/hal+json", true}, | ||
|
||
{"application/bson", false}, | ||
{"application/+json", false}, | ||
{"text/bson", false}, | ||
{"text/+json", false}, | ||
|
||
{"zip/json", false}, | ||
} | ||
|
||
for _, c := range testCases { | ||
actual := sw.JsonCheck.MatchString(c.String) | ||
if actual != c.ShouldMatch { | ||
t.Errorf("Expected %s to result in %v but got %v", c.String, c.ShouldMatch, actual) | ||
} | ||
} | ||
} | ||
|
||
func TestXmlRegex(t *testing.T) { | ||
testCases := []testCase{ | ||
{"application/xml", true}, | ||
{"application/vnd.org.application+xml", true}, | ||
{"application/hal+xml", true}, | ||
{"text/xml", true}, | ||
{"text/vnd.org.application+xml", true}, | ||
{"text/hal+xml", true}, | ||
|
||
{"application/bmx", false}, | ||
{"application/+xml", false}, | ||
{"text/bmx", false}, | ||
{"text/+xml", false}, | ||
|
||
{"zip/xml", false}, | ||
} | ||
|
||
for _, c := range testCases { | ||
actual := sw.XmlCheck.MatchString(c.String) | ||
if actual != c.ShouldMatch { | ||
t.Errorf("Expected %s to result in %v but got %v", c.String, c.ShouldMatch, actual) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.