Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Apex] migrate samples to use OAS v3 spec #6488

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/apex-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g apex -o samples/client/petstore/apex $@"
ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex -DskipFormModel=true $@"

java $JAVA_OPTS -jar $executable $ags
5 changes: 3 additions & 2 deletions samples/client/petstore/apex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ OASClient client = api.getClient();


Map<String, Object> params = new Map<String, Object>{
'body' => ''
'oaSPet' => ''
};

try {
// cross your fingers
api.addPet(params);
OASPet result = api.addPet(params);
System.debug(result);
} catch (OAS.ApiException e) {
// ...handle your exceptions
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ public class OASPetApi {
/**
* Add a new pet to the store
*
* @param body Pet object that needs to be added to the store (required)
* @param oaSPet Pet object that needs to be added to the store (required)
* @return OASPet
* @throws OAS.ApiException if fails to make API call
*/
public void addPet(Map<String, Object> params) {
client.assertNotNull(params.get('body'), 'body');
public OASPet addPet(Map<String, Object> params) {
client.assertNotNull(params.get('oaSPet'), 'oaSPet');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

client.invoke(
return (OASPet) client.invoke(
'POST', '/pet',
(OASPet) params.get('body'),
(OASPet) params.get('oaSPet'),
query, form,
new Map<String, Object>(),
new Map<String, Object>(),
new List<String>(),
new List<String>{ 'application/xml', 'application/json' },
new List<String>{ 'application/json', 'application/xml' },
new List<String> { 'petstore_auth' },
null
OASPet.class
);
}
/**
Expand Down Expand Up @@ -157,24 +158,25 @@ public class OASPetApi {
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store (required)
* @param oaSPet Pet object that needs to be added to the store (required)
* @return OASPet
* @throws OAS.ApiException if fails to make API call
*/
public void updatePet(Map<String, Object> params) {
client.assertNotNull(params.get('body'), 'body');
public OASPet updatePet(Map<String, Object> params) {
client.assertNotNull(params.get('oaSPet'), 'oaSPet');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

client.invoke(
return (OASPet) client.invoke(
'PUT', '/pet',
(OASPet) params.get('body'),
(OASPet) params.get('oaSPet'),
query, form,
new Map<String, Object>(),
new Map<String, Object>(),
new List<String>(),
new List<String>{ 'application/xml', 'application/json' },
new List<String>{ 'application/json', 'application/xml' },
new List<String> { 'petstore_auth' },
null
OASPet.class
);
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ public class OASStoreApi {
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet (required)
* @param oaSOrder order placed for purchasing the pet (required)
* @return OASOrder
* @throws OAS.ApiException if fails to make API call
*/
public OASOrder placeOrder(Map<String, Object> params) {
client.assertNotNull(params.get('body'), 'body');
client.assertNotNull(params.get('oaSOrder'), 'oaSOrder');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

return (OASOrder) client.invoke(
'POST', '/store/order',
(OASOrder) params.get('body'),
(OASOrder) params.get('oaSOrder'),
query, form,
new Map<String, Object>(),
new Map<String, Object>(),
new List<String>{ 'application/xml', 'application/json' },
new List<String>(),
new List<String>{ 'application/json' },
new List<String>(),
OASOrder.class
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,69 +28,69 @@ public class OASUserApi {
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object (required)
* @param oaSUser Created user object (required)
* @throws OAS.ApiException if fails to make API call
*/
public void createUser(Map<String, Object> params) {
client.assertNotNull(params.get('body'), 'body');
client.assertNotNull(params.get('oaSUser'), 'oaSUser');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

client.invoke(
'POST', '/user',
(OASUser) params.get('body'),
(OASUser) params.get('oaSUser'),
query, form,
new Map<String, Object>(),
new Map<String, Object>(),
new List<String>(),
new List<String>(),
new List<String>(),
new List<String>{ 'application/json' },
new List<String> { 'api_key' },
null
);
}
/**
* Creates list of users with given input array
*
* @param body List of user object (required)
* @param oaSUser List of user object (required)
* @throws OAS.ApiException if fails to make API call
*/
public void createUsersWithArrayInput(Map<String, Object> params) {
client.assertNotNull(params.get('body'), 'body');
client.assertNotNull(params.get('oaSUser'), 'oaSUser');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

client.invoke(
'POST', '/user/createWithArray',
(List<OASUser>) params.get('body'),
(List<OASUser>) params.get('oaSUser'),
query, form,
new Map<String, Object>(),
new Map<String, Object>(),
new List<String>(),
new List<String>(),
new List<String>(),
new List<String>{ 'application/json' },
new List<String> { 'api_key' },
null
);
}
/**
* Creates list of users with given input array
*
* @param body List of user object (required)
* @param oaSUser List of user object (required)
* @throws OAS.ApiException if fails to make API call
*/
public void createUsersWithListInput(Map<String, Object> params) {
client.assertNotNull(params.get('body'), 'body');
client.assertNotNull(params.get('oaSUser'), 'oaSUser');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

client.invoke(
'POST', '/user/createWithList',
(List<OASUser>) params.get('body'),
(List<OASUser>) params.get('oaSUser'),
query, form,
new Map<String, Object>(),
new Map<String, Object>(),
new List<String>(),
new List<String>(),
new List<String>(),
new List<String>{ 'application/json' },
new List<String> { 'api_key' },
null
);
}
Expand All @@ -114,7 +114,7 @@ public class OASUserApi {
new Map<String, Object>(),
new List<String>(),
new List<String>(),
new List<String>(),
new List<String> { 'api_key' },
null
);
}
Expand Down Expand Up @@ -189,34 +189,34 @@ public class OASUserApi {
new Map<String, Object>(),
new List<String>(),
new List<String>(),
new List<String>(),
new List<String> { 'api_key' },
null
);
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted (required)
* @param body Updated user object (required)
* @param oaSUser Updated user object (required)
* @throws OAS.ApiException if fails to make API call
*/
public void updateUser(Map<String, Object> params) {
client.assertNotNull(params.get('username'), 'username');
client.assertNotNull(params.get('body'), 'body');
client.assertNotNull(params.get('oaSUser'), 'oaSUser');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();

client.invoke(
'PUT', '/user/{username}',
(OASUser) params.get('body'),
(OASUser) params.get('oaSUser'),
query, form,
new Map<String, Object>{
'username' => (String) params.get('username')
},
new Map<String, Object>(),
new List<String>(),
new List<String>(),
new List<String>(),
new List<String>{ 'application/json' },
new List<String> { 'api_key' },
null
);
}
Expand Down