Swagger-codegen: [PHP] Allow for private Composer repository in documentation

Created on 20 Sep 2016  路  5Comments  路  Source: swagger-api/swagger-codegen

Description

When constructing a PHP client, README.md will include this snippet to add to composer.json:

"repositories": [
    {
        "type": "git",
        "url": "https://github.com/<composerVendorName>/<composerProjectName>.git"
    }
]

As we're generating a private API client with a proper private Composer repo (Satis), usage of our package should include:

"repositories": [
    {
        "type": "composer",
        "url": "https://package.example.com"
    }
]
Swagger-codegen version

@e6049d6d30822c35a13608667637591f6536ad41

Swagger declaration file content or url

config.json

Command line used for generation
swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l php -o . -c ./config.json
Steps to reproduce

There's no way to generate a PHP client without it happening, I don't see a way to provide configuration regarding this. My config.json:

{
    "invokerPackage": "Example",
    "modelPackage": "Example\\Model",
    "apiPackage": "Example\\Api",
    "packagePath": ".",
    "srcBasePath": "src",
    "composerProjectName": "example-php-sdk",
    "composerVendorName": "private"
}

Generated with

swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l php -o . -c ./config.json

Open README.md

Suggest a Fix

Allow for specifying Composer package destination.

PHP Suggestion help wanted

Most helpful comment

@wing328 I might, but as I don't have professional experience with Java (only did assignments in college), would need a second pair of eyes. Guess a WiP PR would be fine?

I have other PHP client-related ideas too so it might be a good start.

All 5 comments

@dkarlovi thanks for the feedback, which sounds reasonable to me.

May I know if you've time to contribute the enhancement to use CLI option (e.g. composerRepositoriesURL) to specify the URL?

@wing328 I might, but as I don't have professional experience with Java (only did assignments in college), would need a second pair of eyes. Guess a WiP PR would be fine?

I have other PHP client-related ideas too so it might be a good start.

@dkarlovi https://github.com/swagger-api/swagger-codegen/pull/977 may serve as a good reference.

FYI. Another way to do it is to customized the template composer.mustache and use it with the -t option.

Cli option does not looks like good solution after considering how complex structure of repositories config can be: https://getcomposer.org/doc/04-schema.md#repositories.

Was this page helpful?
0 / 5 - 0 ratings