-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add withXml option for Go language (#7566)
* Added support for application/xml content-type for GO language Issue #7463 * Added test scripts for Go lang "withXml" feature * Added samples for Go land "withXml" feature. * "withXml" feature for Go language is only available for client.
- Loading branch information
1 parent
8668175
commit ee561fc
Showing
102 changed files
with
6,928 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
SCRIPT="$0" | ||
|
||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
if [ ! -d "${APP_DIR}" ]; then | ||
APP_DIR=`dirname "$SCRIPT"`/.. | ||
APP_DIR=`cd "${APP_DIR}"; pwd` | ||
fi | ||
|
||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" | ||
|
||
if [ ! -f "$executable" ] | ||
then | ||
mvn clean package | ||
fi | ||
|
||
# if you've executed sbt assembly previously it will use that instead. | ||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" | ||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l go -o samples/client/petstore/go/go-petstore-withXml -DpackageName=petstore,withXml=true " | ||
|
||
java $JAVA_OPTS -jar $executable $ags |
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,10 @@ | ||
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar | ||
|
||
If Not Exist %executable% ( | ||
mvn clean package | ||
) | ||
|
||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties | ||
set ags=generate -t modules\swagger-codegen\src\main\resources\go -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l go -o samples\client\petstore\go\go-petstore-withXml -DpackageName=petstore,withXml=true | ||
|
||
java %JAVA_OPTS% -jar %executable% %ags% |
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
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
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
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
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
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
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,24 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof |
23 changes: 23 additions & 0 deletions
23
samples/client/petstore/go/go-petstore-withXml/.swagger-codegen-ignore
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,23 @@ | ||
# Swagger Codegen Ignore | ||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
1 change: 1 addition & 0 deletions
1
samples/client/petstore/go/go-petstore-withXml/.swagger-codegen/VERSION
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 @@ | ||
2.4.0-SNAPSHOT |
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,8 @@ | ||
language: go | ||
|
||
install: | ||
- go get -d -v . | ||
|
||
script: | ||
- go build -v ./ | ||
|
160 changes: 160 additions & 0 deletions
160
samples/client/petstore/go/go-petstore-withXml/README.md
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,160 @@ | ||
# Go API client for petstore | ||
|
||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||
|
||
## Overview | ||
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client. | ||
|
||
- API version: 1.0.0 | ||
- Package version: 1.0.0 | ||
- Build package: io.swagger.codegen.languages.GoClientCodegen | ||
|
||
## Installation | ||
Put the package under your project folder and add the following in import: | ||
```golang | ||
import "./petstore" | ||
``` | ||
|
||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *http://petstore.swagger.io:80/v2* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
*AnotherFakeApi* | [**TestSpecialTags**](docs/AnotherFakeApi.md#testspecialtags) | **Patch** /another-fake/dummy | To test special tags | ||
*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **Post** /fake/outer/boolean | | ||
*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite | | ||
*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **Post** /fake/outer/number | | ||
*FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **Post** /fake/outer/string | | ||
*FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **Patch** /fake | To test \"client\" model | ||
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 | ||
*FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **Get** /fake | To test enum parameters | ||
*FakeApi* | [**TestInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties | ||
*FakeApi* | [**TestJsonFormData**](docs/FakeApi.md#testjsonformdata) | **Get** /fake/jsonFormData | test json serialization of form data | ||
*FakeClassnameTags123Api* | [**TestClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **Patch** /fake_classname_test | To test class name in snake case | ||
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **Post** /pet | Add a new pet to the store | ||
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **Delete** /pet/{petId} | Deletes a pet | ||
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **Get** /pet/findByStatus | Finds Pets by status | ||
*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **Get** /pet/findByTags | Finds Pets by tags | ||
*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **Get** /pet/{petId} | Find pet by ID | ||
*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **Put** /pet | Update an existing pet | ||
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **Post** /pet/{petId} | Updates a pet in the store with form data | ||
*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **Post** /pet/{petId}/uploadImage | uploads an image | ||
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **Delete** /store/order/{order_id} | Delete purchase order by ID | ||
*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **Get** /store/inventory | Returns pet inventories by status | ||
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **Get** /store/order/{order_id} | Find purchase order by ID | ||
*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **Post** /store/order | Place an order for a pet | ||
*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **Post** /user | Create user | ||
*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **Post** /user/createWithArray | Creates list of users with given input array | ||
*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **Post** /user/createWithList | Creates list of users with given input array | ||
*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **Delete** /user/{username} | Delete user | ||
*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **Get** /user/{username} | Get user by user name | ||
*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **Get** /user/login | Logs user into the system | ||
*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **Get** /user/logout | Logs out current logged in user session | ||
*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **Put** /user/{username} | Updated user | ||
|
||
|
||
## Documentation For Models | ||
|
||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) | ||
- [Animal](docs/Animal.md) | ||
- [AnimalFarm](docs/AnimalFarm.md) | ||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) | ||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) | ||
- [ArrayTest](docs/ArrayTest.md) | ||
- [Capitalization](docs/Capitalization.md) | ||
- [Category](docs/Category.md) | ||
- [ClassModel](docs/ClassModel.md) | ||
- [Client](docs/Client.md) | ||
- [EnumArrays](docs/EnumArrays.md) | ||
- [EnumClass](docs/EnumClass.md) | ||
- [EnumTest](docs/EnumTest.md) | ||
- [FormatTest](docs/FormatTest.md) | ||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) | ||
- [List](docs/List.md) | ||
- [MapTest](docs/MapTest.md) | ||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) | ||
- [Model200Response](docs/Model200Response.md) | ||
- [ModelApiResponse](docs/ModelApiResponse.md) | ||
- [ModelReturn](docs/ModelReturn.md) | ||
- [Name](docs/Name.md) | ||
- [NumberOnly](docs/NumberOnly.md) | ||
- [Order](docs/Order.md) | ||
- [OuterBoolean](docs/OuterBoolean.md) | ||
- [OuterComposite](docs/OuterComposite.md) | ||
- [OuterEnum](docs/OuterEnum.md) | ||
- [OuterNumber](docs/OuterNumber.md) | ||
- [OuterString](docs/OuterString.md) | ||
- [Pet](docs/Pet.md) | ||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md) | ||
- [SpecialModelName](docs/SpecialModelName.md) | ||
- [Tag](docs/Tag.md) | ||
- [User](docs/User.md) | ||
- [Cat](docs/Cat.md) | ||
- [Dog](docs/Dog.md) | ||
|
||
|
||
## Documentation For Authorization | ||
|
||
## api_key | ||
- **Type**: API key | ||
|
||
Example | ||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ | ||
Key: "APIKEY", | ||
Prefix: "Bearer", // Omit if not necessary. | ||
}) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
## api_key_query | ||
- **Type**: API key | ||
|
||
Example | ||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ | ||
Key: "APIKEY", | ||
Prefix: "Bearer", // Omit if not necessary. | ||
}) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
## http_basic_test | ||
- **Type**: HTTP basic authentication | ||
|
||
Example | ||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{ | ||
UserName: "username", | ||
Password: "password", | ||
}) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
## petstore_auth | ||
- **Type**: OAuth | ||
- **Flow**: implicit | ||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog | ||
- **Scopes**: | ||
- **write:pets**: modify pets in your account | ||
- **read:pets**: read your pets | ||
|
||
Example | ||
```golang | ||
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING") | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
Or via OAuth2 module to automatically refresh tokens and perform user authentication. | ||
```golang | ||
import "golang.org/x/oauth2" | ||
|
||
/* Perform OAuth2 round trip request and obtain a token */ | ||
|
||
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) | ||
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
|
||
## Author | ||
|
||
[email protected] | ||
|
Oops, something went wrong.