Feature/codegen ignore #2899

merged 1 commit into from May 19, 2016


None yet

2 participants

jimschubert commented May 18, 2016 edited

Looking for feedback and possibly additional testing on this.

Here's a test scenario:

  1. Remove samples/client/petstore/csharp/SwaggerClient
  2. Create samples/client/petstore/csharp/SwaggerClient
  3. Add the following to samples/client/petstore/csharp/SwaggerClient/.swagger-codegen-ignore
# Swagger Codegen Ignore

# This should match build.sh located anywhere.
# Should also work as /build.sh

# Exclude all recursively

# Explicitly allow files excluded by other rules

# Test DirectoryRule

# This shouldn't be included because parent directory is excluded by previous rule.

# Exclude a single, nested file

  1. Verify:
    • build.sh not created
    • only docs/UserApi.md created under docs
    • src/IO.Swagger.Tests/Api/PetApiTests.cs not created under src/IO.Swagger.Tests/Api
    • src/IO.Swagger.Test/Model/AnimalFarmTests.cs not created

see issue #2105

@wing328 wing328 added the Enhancement label May 18, 2016
@wing328 wing328 added this to the v2.2.0 milestone May 18, 2016
@jimschubert jimschubert [feature] Support for .swagger-codegen-ignore
Adds a .swagger-codegen-ignore file with instructions and examples.
The .swagger-codegen-ignore file is treated as a supporting file.

Every project will generate a .swagger-codegen-ignore file containing
instructions and examples.

This also adds support for 'common' files (defaults like
.swagger-codegen-ignore). In the case of the ignore file, a generator
may include a compiled template ignore file which outputs to the
outputDir folder as .swagger-codegen-ignore and the default file
generation will honor the already generated file.

The rules for .swagger-codegen-ignore are a simple subset of what you'd
find in .gitignore or .dockerignore. It supports recursive matching
(**), simple matching (*), matching files in the project root
(/filename), matching against directories (dir/), negation rules

@wing328 I've rebased against master to get rid of the conflicts (there were a few in DefaultGenerator.java).

A main question I have is whether I should add any tests to DefaultGeneratorTest to verify whether or not files get generated as intended. I didn't do this because I thought it might be overkill since it would tightly couple those tests to the folder structure created by a single generator.

Also, I didn't do anything with the existing skipOverwrite functionality.

@wing328 wing328 merged commit 624e8ae into swagger-api:master May 19, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
@jimschubert jimschubert referenced this pull request May 23, 2016

Exclude model tests? #2506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment