Commit Graph

5629 Commits

Author SHA1 Message Date
Logan Patino
12a85bb09d Add enum support for flask (#6684) 2017-10-16 11:34:31 +08:00
Yukio Ejiri
8bcceb4a10 [kotlin] Fix causing NoClassDefFoundError at runtime on Android device (#6661)
* Fix causing NoClassDefFoundError at runtime on Android device.

* Add samples modified by bin/kotlin-client-petstore.sh
2017-10-16 11:05:41 +08:00
Javier Velilla
3067da2877 Swagger eiffel:fix (#6674)
* Updated api client, Required parameters {{#required}} .. {{/required}}, are mapped to Eiffel
Void Safety Rules, optional parameters are translated to detachable TYPE.
Validation Rules are mapped to preconditions, at the moment maximun and minimun
validation has been added.
Improved API_CLIENT.parameter_to_tuple feature to accept a LIST [ANY] instead of LIST [STRING_32].
Improved model template to generate the model output.

* Updated API_CLIENT.parameter_to_string feature, missing STRING representation.

* Updating sample using the latest modifications.
2017-10-16 11:02:19 +08:00
Elias Ovchynnikov
3f7f6b8599 Add operationId as nickname to @ApiOperation (#6688)
* Add operationId as nickname to @ApiOperation

* Refresh samples after adding nicknames to @ApiOperation
2017-10-16 10:18:32 +08:00
stkrwork
027fb2fe47 - Removed unnecessary line in in Restbed Codegen Constructor (#6675)
- Updated samples
2017-10-15 23:38:46 +08:00
Vincent Batts
eb453791b6 golang: trailing whitespace fails gofmt (#6669)
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-10-13 17:02:20 +08:00
naelrashdeen
5ffdee4479 [PHP][Symfony] Generate valid PHP code (#6578)
Fixes #5985

We were experiencing syntax issues when generating the Petstore example. See some of the examples below:

StoreApiInterface.php
namespace Swagger\Server\Api;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Swagger\Server\Model\Order;
**use maparray&lt;string,int&gt;;**
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

UserApiInterface.php
public function createUsersWithArrayInput(**User[]** $body);
public function createUsersWithListInput(User[] $body);
As far as I know, it is not possible to use array of objects in this way.

PetApiInterface.php
namespace Swagger\Server\Api;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Swagger\Server\Model\Pet;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Swagger\Server\Model\ApiResponse;
**use string[];**
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

public function findPetsByStatus(string[] $status);
public function findPetsByTags(string[] $tags);
2017-10-12 17:40:11 +08:00
ehyche
b716b378c4 Swift4: Add additional initializer for initializing model object with properties. (#6642)
* Add addiitional files from upstream

* Remove mis-added files

* Add additional swift4 initializer for initializing model object with properties.

This change fixes this issue: https://github.com/swagger-api/swagger-codegen/issues/6641

It adds an additional initializer which allows model objects to be initialized using the properties. For exxample, if we had this model:

    "ErrorInfo": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "Example Error object"
    },

This we generate an initializer for this model object like this:

    public init(code: Int?, message: String?, details: [String]?) {
        self.code = code
        self.message = message
        self.details = details
    }

* Add hasVars checks around initializers and re-run all scripts to re-generate
2017-10-12 17:35:59 +08:00
Yukio Ejiri
590754f4f4 [kotlin] Fix syntax errors on localVariableHeader in api.mustache (#6660) 2017-10-12 17:31:09 +08:00
Javier Velilla
3bd24c3e5c Updated api client, Required parameters {{#required}} .. {{/required}}, are mapped to Eiffel (#6653)
Void Safety Rules, optional parameters are translated to detachable TYPE.
Validation Rules are mapped to preconditions, at the moment maximun and minimun
validation has been added.
Improved API_CLIENT.parameter_to_tuple feature to accept a LIST [ANY] instead of LIST [STRING_32].
Improved model template to generate the model output.
2017-10-12 17:28:00 +08:00
wing328
30a176126a revise wordings for powershell generator 2017-10-11 21:16:53 +08:00
Jon Schoning
db67840ded [haskell-http-client] bug fixes; path & newtype generation issues (#6638)
* fix path generation/param-substitution issues

* fix newtype de-duplication issues

* refactoring only

* correct version in comments

* prevent duplicate MimeTypes

* sort parameter newtypes
2017-10-10 23:01:48 +08:00
Esteban Marin
dc88ed99ae [angular-typescript] fix using form data (#6574)
* #6457: fix sending form params

* #6457: fix sending form params using files

* #6457: fix sending form params with files for angular 4.3

* #6457: generate samples

* #6457: [typescript-angular] fix form data submission in IE/Edge

* re-apply [typescript-angular] add customized encoder to use '+' char in query parameter #6306 (#6334)

* adapt for HttpClient: [typescript-angular] add customized encoder to use '+' char in query parameter #6306 (#6334)

* generate samples

* #6457: fix url parameter encoder imports for angular <4.3

* #6457: generate samples
2017-10-10 22:55:50 +08:00
ehyche
02d25f5a14 Swift4: Fix inline enum issue (#6640)
* Add addiitional files from upstream

* Remove mis-added files

* Fix compilation issue with Swift4 inline enums.

This change fixes this issue: https://github.com/swagger-api/swagger-codegen/issues/6607

The problem was that I was using "datatype" instead of "datatypeWithEnum" in the model.mustache file.

When you have a the following model property:

"myInlineStringEnum": {
  "type": "string",
  "enum": [
    "inlineStringEnumValue1",
    "inlineStringEnumValue2",
    "inlineStringEnumValue3"
  ]
}

Then we were generating:

public enum MyInlineStringEnum: String, Codable {
  case inlinestringenumvalue1 = "inlineStringEnumValue1"
  case inlinestringenumvalue2 = "inlineStringEnumValue2"
  case inlinestringenumvalue3 = "inlineStringEnumValue3"
}

However, when we decode this, we were using type of the enum ("datatype") rather than the enum type itself ("datatypeWithEnum"). So we were generating:

myInlineStringEnum = try container.decodeIfPresent(String.self, forKey: "myInlineStringEnum")

rather than:

myInlineStringEnum = try container.decodeIfPresent(MyInlineStringEnum.self, forKey: "myInlineStringEnum")
2017-10-10 22:53:17 +08:00
Graham Johnson
1bdb104738 Add Serializable import to JaxRS-spec models if serializableModel is set (#6651) 2017-10-10 22:45:47 +08:00
Jihun Lee
676af62122 Updated feign library dependency to io.github.openfeign (#6652)
Changed groupId from “com.netflix.feign” to “io.github.openfeign” from
gradle and sbt mustache templates.
2017-10-10 22:41:18 +08:00
wing328
3b134319fa add java version to pom in resteasy eap java8 2017-10-09 22:51:58 +08:00
Jean-François Côté
e6d4362012 Fix for regression in issue: https://github.com/swagger-api/swagger-codegen/issues/6472 (#6480) 2017-10-09 22:51:32 +08:00
wing328
164f5bbb72 fix underscore to handle spaces (#6637) 2017-10-09 09:28:31 +08:00
wing328
81e0357561 fix NPE reported in #6519 (#6635) 2017-10-08 18:38:23 +08:00
Sasa Vilic
41b7950dcd Fix class path for DeferredResult (#6452) 2017-10-08 18:29:48 +08:00
Lukasz Konopski
73b38dd19e #3904 Inheritance support java client retrofit gson (#4729)
* merge with master

* remove zoo specific artifact names

* fix duplicate doublequote

* #3904 add samples for retrofit2

* #3904 clean json field retrieval

* #3904 allow non-abstract parent class
2017-10-08 18:25:38 +08:00
Halil İbrahim Şener
1f9f8c5a3e [JavaScript] Fix licenseNames (#6605)
* [JavaScript] Fix licenseName in package.mustache

* Fix invalid SPDX license expression in resources/2_0

* Update JavaScript samples
2017-10-08 17:15:21 +08:00
jarlesat
8a7940f199 Issue 5431 Support jaxrs client api interfaces (#6412)
* Adds the ability to create code for an interface-based jaxrs client.

* Adds shell script and sample files for jaxrs-spec-interface

* rebase into adds shell

* Fixes bug in creation of Produces/Consumes in method annotation. Allows for instance "application/json; charset=utf-8"

* Fixes generated pom.xml

* Generate pom.xml by default

* Prettier output from api.mustache

* Fixes bug in mediatype, allowing charset-specification in swagger.yaml.

* Merges generation of interface-based jaxrs client/api into jaxrs-spec.

* Moves jaxrs-spec server interface to match location of jaxrs-spec server

* Makes Generated-annotation in genereated classes slightly prettier.
2017-10-08 15:28:12 +08:00
Adrian Moos
eab9c72a42 represent swagger enums as union of literal types (#6233)
* represent swagger enums as union of literal types

enabling their easy use in angular templates, structural subtyping
among enums (in particular, different instances of the same enum
are now mutually assignable), improving type safety by preventing
incorrect widening, and permitting numeric enum values
(albeit without descriptive names)

Fixes #6206, #5146, #3500

* update samples

* restore blank lines at end of file

* fix typo
2017-10-07 21:42:46 +08:00
Greg Marzouka
cc756b5563 [Scala] Properly handle csv collectionFormat (#6540)
* Add support for lists of path parameters (eg instances), and default params for optional case classes

* Update Petstore sample

* Revert defaulting of case class fields to None

* Update Petstore sample
2017-10-07 18:24:08 +08:00
Jon Schoning
5b32e886f4 [haskell-http-client] add support for auth methods (#6622)
* add support for auth methods

* use newtypes for required params

* fix duplicate operationId issues

* prevent aliasing of vendorextension references in fromOperation

* add --fast to stack ci build
2017-10-07 17:12:48 +08:00
Andrea Rossi
0db4b32384 [objc] Let the developer specify the timezone to be used for date serialisation (#6628)
* [objc] Update deployment target to 8.0

Updates the test project deployment target to 8.0, as that's the lowest
supported by the latest XCode.

* [objc] Update petstore tests based on current master

Makes sure the tests are based on the latest version of master.

* [objc] Allow specifying the serialization timezone

Now it's possible to specify the timezone used for serializing dates
2017-10-07 13:44:35 +08:00
Gareth T
567ae3fd12 [GO CLIENT] Fix issue with generating code for API key (#6630)
* [GO CLIENT] Fix Go security query parameter generation by using correct string literal and using the Add method.

* Add generated files.
2017-10-07 12:05:48 +08:00
Akihito Nakano
42313af7a1 [PHP] Fix: Type object not handled properly in setParameterExampleValue (#6619)
* Add test which reproduce the warning #5338

https://github.com/swagger-api/swagger-codegen/issues/5338#issuecomment-292502895
`[main] WARN io.swagger.codegen.languages.PhpClientCodegen - Type object not handled properly in setParameterExampleValue`

* Fix Type object not handled properly in setParameterExampleValue

* Update samples

- /bin/php-petstore.sh
- /bin/security/php-petstore.sh
2017-10-06 15:56:13 +08:00
wing328
2f98ade693 fix inconsistent java naming (#6624) 2017-10-06 11:03:15 +08:00
niku
86803c0c24 [Elixir] Improve Elixir Client about primitive type spec (#6623)
Fix following dialyzer warnings in the sample:

```
:0: Unknown type 'Elixir.Float':t/0
:0: Unknown type 'Elixir.Integer':t/0
```
2017-10-06 09:16:27 +08:00
Brian
61b910fb82 [R] Added ApiClient and fixed other issues (#6571)
* Added namespace mustache to be generated

* Fixed syntax issues with package generation

* Added Response and Element mustache templates

* Added ApiClient

* Fix: Only required parameters needed for api operations

* Added documentation generated code

* Regenerated petstore samples

* Fixed url paths for operations

* Fixed based on comments in issues #6520

* Regenerated petstore samples
2017-10-05 01:07:06 +08:00
Cédric Grard
e49e7a056b Typo error fix (#6620) 2017-10-04 22:46:06 +08:00
Stephane Carrez
90010da61d [Ada] Adding Ada support for client code generator (#6602)
* Ada language support (generic generator)

Implement the AbstractAdaCodegen class with the Ada keywords and global
behavior for Ada language

* Ada language support (main generator)

Implement the AdaCodegen class for the Ada client and server code generator
Initial implementation based on a mix from CppRestClientCodegen, NodeJSServerCodegen

* Ada language support: register the AdaCodegen generator class

* Ada language license template

* Ada language model templates (spec and body)

* Ada language client spec and body templates

* Ada language server spec and body templates

* Fix escaping Ada keywords for parameter name

* Generate GNAT project and update type mappings
- Use 'p_' as escape prefix for parameter names because identifiers are not allowed to start with '_'
- Add GNAT project file generation
- Update the type mappings to use the Swagger package types

* Fix generation of operations with no parameters

* Fix instantiation of Ada.Containers.Vectors package in generated model files

* New template for the GNAT project file generation

* Fix datatype generation for Ada language
- Override the getTypeDeclaration function to specify the datatype
- Fix definition of language predefined types

* Add a Serialize procedure declaration for the Ada model generation

* Add a Serialize procedure for the Ada template model generation

* Fix operation name and parameter name for Ada
- Declare and implement toAdaIdentifier function to verify and turn some identifier
  to Ada identifier following Ada style
- Override toOperationId and use toAdaIdentifier for generation of operation name
- Update toParamName to use toAdaIdentifier

* Media type support for Ada code generator
- Implement postProcessMediaTypes function to add a 'adaMediaType' member
  to each media type and map it to some Ada enumeration
- Post process the 'produces' and 'consumes' media type of an operation

* Use x-has-notes extension to avoid emitting notes when they are empty

* First generation for Ada client operation body

* Add a x-has-uniq-produces and x-has-uniq-consumes to media types
to indicate that the list contains only one item, this is necessary
for Ada generator for generation of arrays with one item only

* Add a postProcessParameter for Ada code generator to emit a x-is-model-type attribute

* Update Ada client body template for the serialization of data

* Fix postProcessParameter in Ada code generator to take into account file parameters

* Update the Ada client body to support form parameters

* Fix type name used for mapped types in the Ada generator

* Declare a Deserialize procedure for the Ada generated model

* Override the fromOperation for Ada client code generator
- Emit a x-codegen-response extension with the response description type
- Emit a x-id-model-type extension for each type property

* Update the Ada client package spec template to declare the result type

* Add support to extract response and return result in Ada client code

* Fix Ada postProcessModels to handle container properties and emit a correct x-is-model-type attribute

* Add support for Deserialize procedure in the Ada model generator

* Fix indentation of generated Ada client body package

* Add projectName option to configure the GNAT project name

* Update the GNAT project name for the Ada code generator

* Cleanup implementation and remove unused code

* Cleanup implementation and remove unused code

* Fix javadoc errors

* Use 'ada' for the language name to follow swagger-codegen convention
Add (beta) to the help description
Fix a NPE that occurs with incomplete yaml descriptions
2017-10-04 11:51:04 +08:00
wing328
bf74e33c52 rename CsharpDotNet2 to csharp-dotnet2 (#6611) 2017-10-04 00:03:35 +08:00
wing328
5175281f32 rename silex-PHP to php-silex (#6612) 2017-10-03 23:46:56 +08:00
Pierre Deman
74e31699da CsharpDotNet2Client - Use clientPackage in additionalProperties (#6581)
* CsharpDotNet2Client - Use clientPackage in additionalProperties if provided

* Give execution rights for csharp-dotnet2-petstore.sh

* Fix generation of C#.net2 apiPackage, modelPackage, clientPackage

* Fix modelPackage property missing when generating models

* Initialize clientPackage in constructor
2017-10-03 16:58:27 +08:00
craffael
1896e96648 [nancyfx] fix interface prefix (#6595)
* Retrofit2: Return ResponseBody if response if file.

Until now
--------------------
If a swagger endpoint returned a file (e.g. an image), then the Retrofit2
template has choosen the return type java.io.File. However, retrofit cannot
deal with this and throws a com.google.gson.stream.MalformedJsonException.

New:
-------------------
If a swagger endpoint returns a file, then the corresponding Retrofit2 endpoint
will return a okhttp3.ResponseBody which can be used to retrieve the file.

* fix Interface Prefix
2017-10-03 15:14:28 +08:00
wing328
28a5b74dbf add partial header to haskell http client (#6606) 2017-10-02 23:52:01 +08:00
Trond Bolsø
44bf1d69cb Fix for self-referential imports in typescript-angular client (#6450) 2017-10-02 11:24:08 +08:00
craffael
1f4013e7f1 [NancyFx] provide option to override package context (#6593)
* Retrofit2: Return ResponseBody if response if file.

Until now
--------------------
If a swagger endpoint returned a file (e.g. an image), then the Retrofit2
template has choosen the return type java.io.File. However, retrofit cannot
deal with this and throws a com.google.gson.stream.MalformedJsonException.

New:
-------------------
If a swagger endpoint returns a file, then the corresponding Retrofit2 endpoint
will return a okhttp3.ResponseBody which can be used to retrieve the file.

* Add the option packageContext for nancyFx which allows a better adjustment of the namespace.

* run nancyfx-petstore-server.bat
2017-10-02 11:10:09 +08:00
Benjamin Douglas
6e7ad13e1b Pre-calculate type aliases before processing models (#6559)
A type alias in this context is where a model is simply another name for a
primitive type, such as `MyString` in the following model definitions:

    MyList:
      type: array
      items:
        $ref: '#/definitions/MyString'
    MyString:
      type: string

It is valid to use a type alias as a property in another object or array model,
even if the object/array is defined before the alias is, as in the example
above. However, the current alias logic only looks "back" in list of previously
defined models, meaning that `MyList` would not know that `MyString` is an
alias. This change fixes the incorrect behavior by pre-calculating the list of
aliases before any models are processed. It also changes the test endpoint to
verify the correct behavior even when an object is defined before an alias it
uses.
2017-10-02 10:54:41 +08:00
Jon Schoning
8bd7d3912b [haskell-http-client] fixes for fake-endpoints (#6597)
* fix compile errors / sanitization for petstore-with-fake-endpoints-models-for-testing.yaml
* correct mimetype logic
* add makefile
2017-10-01 18:18:46 +08:00
wing328
82b6e81897 use String() to convert num, update TS angular samples 2017-09-30 17:28:07 +08:00
wing328
f3e19e0fdc fix comma in method without parameters 2017-09-30 17:23:38 +08:00
Adrian Moos
da37f40202 Add optional support for HttpClient (#6295)
* fix compilation error in eclipse

by updating package declarations in moved files
(eclipse validates that package and folder names match)

* permit specifying the full angular version

simplifying the templates by moving trivial case splits to the model

* remove dead code

this method is never called ...

* support HttpClient in addition to Http, clean up generated code

Fixes #6080

* added new sample, and regenerated existing samples

* updated samples

this time with the freshly build generator ...

* improve formatting

* updated samples

* fix compilation error in generated code

the overload for blobs does not have a type parameter

* added the first test for the utils package

* fix extra trainling commas in function argument lists

* regenerated samples
2017-09-30 17:19:39 +08:00
Jinkui Shi
063e885c2f [Scala] format the Scala code style templete (#6532)
* The templete of scala code style refactor

* more reformat

* more reformat

* generate petstore client
2017-09-29 17:24:34 +08:00
Vlad Frolov
924a8e5efe [CPPREST] Fixed multipart files upload implementation (#6518) 2017-09-29 15:46:16 +08:00
Akito Nozaki
25812fc526 Swift3: non dictionary body type (#6531)
* Adding support for non dictionary body types.

* Adding test for rest of the swift3 types

* Cleaning up implementation of makeRequest and adding better error handling.

* Adding ClientError for error produced before request is sent.

* Changing how encoding of body data is handled.

* Cleaning up code that was modified.
2017-09-29 00:16:32 +08:00