openapi-generator/CONTRIBUTING.md

104 lines
8.1 KiB
Markdown
Raw Normal View History

2015-12-07 08:38:07 +00:00
# Guidelines For Contributing
2015-12-07 08:36:32 +00:00
## Before submitting an issue
2018-05-04 11:44:01 +00:00
- If you're not using the latest master to generate API clients or server stubs, please give it another try by pulling the latest master as the issue may have already been addressed. Ref: [Getting Started](https://github.com/openapitools/openapi-generator#getting-started)
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) and [closed issue](https://github.com/openapitools/openapi-generator/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
- File an [issue ticket](https://github.com/openapitools/openapi-generator/issues/new) by providing all the required information.
- Test with the latest master by building the JAR locally to see if the issue has already been addressed.
2016-06-08 13:21:39 +00:00
- You can also make a suggestion or ask a question by opening an "issue".
2015-12-07 08:36:32 +00:00
## Before submitting a PR
2018-05-04 11:44:01 +00:00
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change.
- If no one has suggested something similar, open an ["issue"](https://github.com/openapitools/openapi-generator/issues) with your suggestion to gather feedback from the community.
2018-10-18 14:53:47 +00:00
- If you're adding a new option to a generator, please consider using the `-t` option with customized templates instead or start a discussion first by opening an issue as we want to avoid adding too many options to the generator.
2016-07-04 23:46:42 +00:00
- It's recommended to **create a new git branch** for the change so that the merge commit message looks nicer in the commit history.
2015-12-07 08:36:32 +00:00
## How to contribute
### git
If you're new to git, you may find the following FAQs useful:
2018-05-04 11:44:01 +00:00
https://github.com/openapitools/openapi-generator/wiki/FAQ#git
### Branches
Please file the pull request against the correct branch, e.g. `master` for non-breaking changes. See the [Git Branches](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches) page for more information.
2015-12-07 08:36:32 +00:00
### Code generators
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
2015-12-07 08:36:32 +00:00
### Templates
All the templates ([mustache](https://mustache.github.io/)) can be found in [modules/openapi-generator/src/main/resources](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources).
2015-12-07 08:36:32 +00:00
2018-05-04 11:44:01 +00:00
For a list of variables available in the template, please refer to this [page](https://github.com/openapitools/openapi-generator/wiki/Mustache-Template-Variables)
2015-12-07 08:36:32 +00:00
### Style guide
2016-11-28 15:57:10 +00:00
Code change should conform to the programming style guide of the respective languages:
2017-10-08 04:08:45 +00:00
- Ada: https://en.wikibooks.org/wiki/Ada_Style_Guide/Source_Code_Presentation
2016-06-13 16:18:48 +00:00
- Android: https://source.android.com/source/code-style.html
- Bash: https://github.com/bahamas10/bash-style-guide
2015-12-07 08:36:32 +00:00
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
2016-06-23 10:08:56 +00:00
- C++: https://google.github.io/styleguide/cppguide.html
2017-07-04 11:09:18 +00:00
- C++ (Tizen): https://wiki.tizen.org/Native_Platform_Coding_Idiom_and_Style_Guide#C.2B.2B_Coding_Style
- Clojure: https://github.com/bbatsov/clojure-style-guide
2018-01-30 03:06:42 +00:00
- Dart: https://www.dartlang.org/guides/language/effective-dart/style
- Elixir: https://github.com/christopheradams/elixir_style_guide
- Eiffel: https://www.eiffel.org/doc/eiffel/Coding%20Standards
- Erlang: https://github.com/inaka/erlang_guidelines
2016-06-13 16:52:34 +00:00
- Haskell: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
2015-12-07 08:36:32 +00:00
- Java: https://google.github.io/styleguide/javaguide.html
- JavaScript: https://github.com/airbnb/javascript/
- Kotlin: https://kotlinlang.org/docs/reference/coding-conventions.html
2016-06-13 16:53:57 +00:00
- Groovy: http://groovy-lang.org/style-guide.html
2016-04-07 06:43:32 +00:00
- Go: https://github.com/golang/go/wiki/CodeReviewComments
2015-12-07 08:36:32 +00:00
- ObjC: https://github.com/NYTimes/objective-c-style-guide
2016-04-07 06:43:32 +00:00
- Perl: http://perldoc.perl.org/perlstyle.html
2015-12-07 08:36:32 +00:00
- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
- PowerShell: https://msdn.microsoft.com/en-us/library/dd878270(v=vs.85).aspx
2015-12-07 08:36:32 +00:00
- Python: https://www.python.org/dev/peps/pep-0008/
2017-08-25 14:52:55 +00:00
- R: https://google.github.io/styleguide/Rguide.xml
2015-12-07 08:36:32 +00:00
- Ruby: https://github.com/bbatsov/ruby-style-guide
- Rust: https://github.com/rust-lang-nursery/fmt-rfcs/blob/master/guide/guide.md (the default [rustfmt](https://github.com/rust-lang-nursery/rustfmt) configuration)
2016-06-13 16:53:57 +00:00
- Scala: http://docs.scala-lang.org/style/
- Swift: [Apple Developer](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html)
2015-12-07 08:36:32 +00:00
- TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines
For other languages, feel free to suggest.
You may find the current code base not 100% conform to the coding style and we welcome contributions to fix those.
For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#vendorExtensions), please follow the naming convention below:
- For general vendor extension, use lower case and hyphen. e.g. `x-is-unique`, `x-content-type`
2016-11-28 15:57:10 +00:00
- For language-specified vendor extension, put it in the form of `x-{lang}-{extension-name}`. e.g. `x-objc-operation-id`, `x-java-feign-retry-limit`
2018-05-04 11:44:01 +00:00
- For a list of existing vendor extensions in use, please refer to https://github.com/openapitools/openapi-generator/wiki/Vendor-Extensions. If you've added new vendor extensions as part of your PR, please update the wiki page.
2015-12-07 08:36:32 +00:00
### Testing
To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen)
2015-12-07 08:36:32 +00:00
To test the templates, please perform the following:
- Update the Petstore sample by running the shell script under `bin` folder. For example, run `./bin/ruby-client-petstore.sh` to update the Ruby PetStore API client under [`samples/client/petstore/ruby`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/ruby) For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion)
2015-12-07 08:36:32 +00:00
- Run the tests in the sample folder, e.g. in `samples/client/petstore/ruby`, run `mvn integration-test -rf :RubyPetstoreClientTests`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests)
- Finally, git commit the updated samples files: `git commit -a`
(`git add -A` if added files with new test cases)
2018-10-18 14:53:47 +00:00
- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml)
2015-12-07 08:36:32 +00:00
To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all the required tools installed to run tests for different languages) or you can leverage http://travis-ci.org to run the CI tests by adding your own openapi-generator repository.
2015-12-07 08:36:32 +00:00
### Tips
- Smaller changes are easier to review
2015-12-30 22:52:15 +00:00
- [Optional] For bug fixes, provide a OpenAPI Spec to repeat the issue so that the reviewer can use it to confirm the fix
2015-12-07 08:36:32 +00:00
- Add test case(s) to cover the change
- Document the fix in the code to make the code more readable
- Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests)
2018-05-04 11:44:01 +00:00
- File a PR with meaningful title, description and commit messages.
2017-01-12 15:36:43 +00:00
- Recommended git settings
- `git config --global core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
2017-07-25 07:09:38 +00:00
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))