wing328 ae8a123484 [WIP][Scala] Finch generator (#3905)
* Feature/objc tasks 2.3.0 (#3522)

* change api and ApiClient to return cancellable NSURLSessionTasks instead of NSNumber

* define a configuration protocol for custom configurations, which can be passed to api clients instead of a global configuration, provide a default implementation with a singleton option

* integrate a workaround for a current JSONModel concurrency bug

* update to new ISO8601 pod

* add missing call to super

* integrate new templates into codegen

* updates documentation templates

* updates petstore objc generated code

* fixes objc client tests

* [ObjC] Add version define and share default headers of each client

* add finch generator and resource

* update license, add errros

* Fix problem with multitheard api client

* fix some errors for finch

* [finch] Remove license header

* [finch] Remove finatra stuff, fix a few issues

* WIP: Finch server generator

* [finch] WIP: server generator impl

This puts parameters (input/output) in the right format. Currently, this
is done in the generator class using vendorExtensions, but should be
refactored to imported templates to clean up.

Previous commits of the server generator output to appropriate
models/api directories. I've made no changes to this logic, but code
currently generates to the root scala package directory. This will need
to be fixed.

There's also an issue with circe's and Option[Date] in the Order type.
This issue will need to be resolved. As well, there's some unused
imports to clean up.

Initial implementation lacks support for custom imports, type mappings,
etc.

* [finch] Update api/model package and imports

* [finch] Explicit import/type mappings

* [finch] Regenerate example
2017-01-29 12:15:39 +08:00

14 KiB

SWGPetApi

All URIs are relative to http://petstore.swagger.io/v2

Method HTTP request Description
addPet POST /pet Add a new pet to the store
deletePet DELETE /pet/{petId} Deletes a pet
findPetsByStatus GET /pet/findByStatus Finds Pets by status
findPetsByTags GET /pet/findByTags Finds Pets by tags
getPetById GET /pet/{petId} Find pet by ID
updatePet PUT /pet Update an existing pet
updatePetWithForm POST /pet/{petId} Updates a pet in the store with form data
uploadFile POST /pet/{petId}/uploadImage uploads an image

addPet

-(NSURLSessionTask*) addPetWithBody: (SWGPet*) body
        completionHandler: (void (^)(NSError* error)) handler;

Add a new pet to the store

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


SWGPet* body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Add a new pet to the store
[apiInstance addPetWithBody:body
          completionHandler: ^(NSError* error) {
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->addPet: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
body SWGPet* Pet object that needs to be added to the store [optional]

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deletePet

-(NSURLSessionTask*) deletePetWithPetId: (NSNumber*) petId
    apiKey: (NSString*) apiKey
        completionHandler: (void (^)(NSError* error)) handler;

Deletes a pet

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


NSNumber* petId = @789; // Pet id to delete
NSString* apiKey = @"apiKey_example"; //  (optional)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Deletes a pet
[apiInstance deletePetWithPetId:petId
              apiKey:apiKey
          completionHandler: ^(NSError* error) {
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->deletePet: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
petId NSNumber* Pet id to delete
apiKey NSString* [optional]

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

findPetsByStatus

-(NSURLSessionTask*) findPetsByStatusWithStatus: (NSArray<NSString*>*) status
        completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error)) handler;

Finds Pets by status

Multiple status values can be provided with comma separated strings

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


NSArray<NSString*>* status = @[@"available"]; // Status values that need to be considered for filter (optional) (default to available)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Finds Pets by status
[apiInstance findPetsByStatusWithStatus:status
          completionHandler: ^(NSArray<SWGPet>* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->findPetsByStatus: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
status NSArray<NSString>** Status values that need to be considered for filter [optional] [default to available]

Return type

NSArray*

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

findPetsByTags

-(NSURLSessionTask*) findPetsByTagsWithTags: (NSArray<NSString*>*) tags
        completionHandler: (void (^)(NSArray<SWGPet>* output, NSError* error)) handler;

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


NSArray<NSString*>* tags = @[@"tags_example"]; // Tags to filter by (optional)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Finds Pets by tags
[apiInstance findPetsByTagsWithTags:tags
          completionHandler: ^(NSArray<SWGPet>* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->findPetsByTags: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
tags NSArray<NSString>** Tags to filter by [optional]

Return type

NSArray*

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getPetById

-(NSURLSessionTask*) getPetByIdWithPetId: (NSNumber*) petId
        completionHandler: (void (^)(SWGPet* output, NSError* error)) handler;

Find pet by ID

Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];

// Configure API key authorization: (authentication scheme: api_key)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];


NSNumber* petId = @789; // ID of pet that needs to be fetched

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Find pet by ID
[apiInstance getPetByIdWithPetId:petId
          completionHandler: ^(SWGPet* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->getPetById: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
petId NSNumber* ID of pet that needs to be fetched

Return type

SWGPet*

Authorization

petstore_auth, api_key

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

updatePet

-(NSURLSessionTask*) updatePetWithBody: (SWGPet*) body
        completionHandler: (void (^)(NSError* error)) handler;

Update an existing pet

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


SWGPet* body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Update an existing pet
[apiInstance updatePetWithBody:body
          completionHandler: ^(NSError* error) {
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->updatePet: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
body SWGPet* Pet object that needs to be added to the store [optional]

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

updatePetWithForm

-(NSURLSessionTask*) updatePetWithFormWithPetId: (NSString*) petId
    name: (NSString*) name
    status: (NSString*) status
        completionHandler: (void (^)(NSError* error)) handler;

Updates a pet in the store with form data

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


NSString* petId = @"petId_example"; // ID of pet that needs to be updated
NSString* name = @"name_example"; // Updated name of the pet (optional)
NSString* status = @"status_example"; // Updated status of the pet (optional)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// Updates a pet in the store with form data
[apiInstance updatePetWithFormWithPetId:petId
              name:name
              status:status
          completionHandler: ^(NSError* error) {
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->updatePetWithForm: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
petId NSString* ID of pet that needs to be updated
name NSString* Updated name of the pet [optional]
status NSString* Updated status of the pet [optional]

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]

uploadFile

-(NSURLSessionTask*) uploadFileWithPetId: (NSNumber*) petId
    additionalMetadata: (NSString*) additionalMetadata
    file: (NSURL*) file
        completionHandler: (void (^)(NSError* error)) handler;

uploads an image

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];


NSNumber* petId = @789; // ID of pet to update
NSString* additionalMetadata = @"additionalMetadata_example"; // Additional data to pass to server (optional)
NSURL* file = [NSURL fileURLWithPath:@"/path/to/file.txt"]; // file to upload (optional)

SWGPetApi*apiInstance = [[SWGPetApi alloc] init];

// uploads an image
[apiInstance uploadFileWithPetId:petId
              additionalMetadata:additionalMetadata
              file:file
          completionHandler: ^(NSError* error) {
                        if (error) {
                            NSLog(@"Error calling SWGPetApi->uploadFile: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
petId NSNumber* ID of pet to update
additionalMetadata NSString* Additional data to pass to server [optional]
file NSURL* file to upload [optional]

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json, application/xml

[Back to top] [Back to API list] [Back to Model list] [Back to README]