swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.08k stars 6.03k forks source link

Upgrade API server integration tests to use Fake Petstore spec #5419 #5420

Open wing328 opened 7 years ago

wing328 commented 7 years ago
Description

petstore-with-fake-endpoints-models-for-testing.yaml covers a lot more edge cases when comparing with the original one (petstore.yaml)

We'll need to to update petstore.yaml with petstore-with-fake-endpoints-models-for-testing.yaml so to ensure the edge cases are covered moving forward.

API servers using petstore-with-fake-endpoints-models-for-testing.yaml:

If anyone wants to work on the enhancement, please reply to let us know. Thank you!

kenisteward commented 7 years ago

@wing328 Let me know if I have this correct. You just want to go back through for all of the tests and update petstore.yaml to petstore-with-fake-endpoints-models-for-testing.yaml for all of the .sh and .bat files correct?

Or do you only want it updated for the ones that can generate servers? e.g. node but not typescript-angular becauese that can only be a browser client lib not a server client lib.

wing328 commented 7 years ago

@kenisteward this "issue" is for server generators only.

kenisteward commented 7 years ago

Alright I'll handle this. Should the list be updated to these? C# (ASP.NET Core, NancyFx), Erlang, Go, Haskell, Java (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy), PHP (Lumen, Slim, Silex, Zend Expressive), Python (Flask), NodeJS, Ruby (Sinatra, Rails5), Scala (Finch, Scalatra)

Got them from the initial readme. Since you can't have an Typescript Angular server, however it might be possible to have an typescript-jquery server i just don't think we generate them.

kenisteward commented 7 years ago

@wing328 I've Done the first of the Servers as a part of #5595. Let me know if anything else needs changed

wing328 commented 7 years ago

@kenisteward I've removed Typescript in the list. Thanks for pointing it out.

ybelenko commented 6 years ago

@wing328 I'm trying to update server Slim generator and spotted small issue: Related endpoint in petstore-with-fake-endpoints-models-for-testing.yaml:

get:
      tags:
        - fake
      summary: To test enum parameters
      description: To test enum parameters
      operationId: testEnumParameters
      consumes:
        - "*/*"
      produces:
        - "*/*"
      parameters:

Produces PHP syntax error:

/**
 * GET testEnumParameters
 * Summary: To test enum parameters
 * Notes: To test enum parameters
 * Output-Formats: [*/*]
 */
$app->GET('/v2/fake', function($request, $response, $args) {

Should I somehow escape */* value inside SlimFrameworkServerCodegen.java?

ybelenko commented 6 years ago

@wing328 I've updated Slim codegen and now */* in comment escaped like this:

/**
 * GET testEnumParameters
 * Summary: To test enum parameters
 * Notes: To test enum parameters
 * Output-Formats: [*\/*]
 */
$app->GET('/v2/fake', function($request, $response, $args) {

Next I'm going to fix broken models:

<?php
/*
 * $Special[modelName]
 */
namespace \Models;

/*
 * $Special[modelName]
 */
class $Special[modelName] {
    /* @var int $specialPropertyName  */
    private $specialPropertyName;
}
<?php
/*
 * 200Response
 */
namespace \Models;

/*
 * 200Response
 */
class 200Response {
    /* @var int $name  */
    private $name;
/* @var string $class  */
    private $class;
}

There are also models with Return and List names which is keywords in PHP and cannot be used as class names. What should I do with all these model names? Should I prefix them forcefully with something inside codegen? Should I strip special chars from model name $Special[modelName]?

ybelenko commented 6 years ago

@wing328 Found pretty good implementation of toModelName in PHPClientCodegen.java and model names are solved now.

7698 issue appeares:

Slim Application Error:
Type: FastRoute\BadRouteException
Message: Static route "/v2/user/logout" is shadowed 
by previously defined variable route "/v2/user/([^/]+)" 
for method "GET"

If @edwd is right in topic above, we cannot sort route paths inside codegen. Maybe we need to throw warnings when routes overlaps.