* Added http module draft * Added generic enum * Modified http lib, added config & middleware definition to ts-fetch * Added model generation with imports * Added auth module * Added servers * Added sample for typescript client * WIP: Models & API * Updated auth * WIP: api modeling * Implemented RequestFactory and Processor completely * Implemented fetch client * Ignore dist folder in typescript client sample * Added middleware to fetch * Restructured TypeScript generator * Reverted: http library.send returns string again * Removed TODOs * Added pom.xml files to TypeScript PetStore client samples * Removed tabs from TypeScriptClientCodegen * Added ts client codegen to root pom.xml and travis * Added server variable configuration to ts-refactor * [TS-Refactor] Added tests for Object Serializer * Added simple test for PetApi * Fixed ObjectSerializer test * Added handling for different http status codes and test for deletePet * Removed tabs in TypeScriptClientCodegen * Removed tabs in DefaultCodegen * Additional tests for pet store api * Fixed file uploads * Made api call configuration separately settable * Use string union for enums * Remove tab * Restructured module layout * Use observables internally * Added promise based middleware * Made discriminator and attributeTypeMap readonly * Configure discriminator correctly * Set discriminator value automatically * Fixed date-time and date handling * Added comments & license info * Added comments * Ignore openapi-generator-cli/bin * Removed accidentally created generated code * Fixed compilation issues in TypeScriptClientCodegen * Added typescript to docs/generators * Updated docs * Added gitignore and git_push * Added jquery library * Added pom.xmls, fixed packagejsons and hopefully webppack * Removed tabs in TypeScriptClientCodegen * Fixed a couple issues with pom.xml * Ensured up to date * Fixed missing fetch definition in TS default tests * Updated typescript docs * Refactor typescript merge master (#4319) Merge master into ts-refactor * Typescript refactor: stub rxjs (#4424) * Remove unused supportsES6 field from codegen * Add a new switch for RXJS * Remove redundant npm dependency on rxjs4 types * Fix return type of PromiseMiddleware methods * Install webpack dependency to run jquery tests * Update form-data to 2.5 which includes typings * Add missing dependency on node typings * Fix test artifact name typo * Stub rxjs when it is not explicitly enabled * Typescript refactor: Platform select for browser and node (#4500) * Use string form of filename parameter This works for the form-data library and is also compatible with the browser FormData object. * Add new option to select platform node or browser When no platform is selected, a default is chosen by the framework option and likewise the file data type option is implied by the platform. * Remove redundant import of node dns module * Only use form-data library for node platform * Generate npm package from npmName option * Use method convertPropertyToBooleanAndWriteBack * Generate typescript samples with ensure-up-to-date * Removed tab from DefaultCodegen * Readded missing change * Mark typescript client codegen as experimental * Removed whitespace * [TS-Refactor] Top-level exports for fetch & jquery (#6138) * Added top-level exports * Updated generator README * Updated typescript generator docs * Allow browsers File type for files (#5521) * Allow passing file parameters as File objects * Add test for jquery upload * Use HttpFile object for node platform * Regenerate samples This is by far the most common use case. A `File` object already contains the name attribute. This commit allows that information to be used directly. When sending a `Blob`, in most browsers the `File` constructor can be used to assign a file name. In all other browsers the alternative is ```typescript Object.assign(data, { name: "foobar.txt" }); ``` That is why we explicitely pass the name as third parameter to `FormData.append`. This `Object.assign` method also works for `Buffer` objects in node. If one really does not want to touch the data object in the browser it is possible to define another reference to the data with ```typescript new Blob([data], { type: data.type }) ``` or in node via ```typescript Buffer.from(data) ``` * [TS-Refactor] Added options for npm version, repository, name and updated readme (#6139) * Added options for npm version, repository, name and updated readme * Removed `this` where not required * Updated typescript docs * Typescript refactor fixes (#6027) Fixes a handful of issues identified in https://github.com/OpenAPITools/openapi-generator/issues/802#issuecomment-617262139 List of changes * Clean: Remove redundant cliOption definition * Remove redundant directory structure in templates If we need to have different index.ts files for the different frameworks, we can mostly do that in the one mustache file. In the cases where that is not possible, we can still add a new override file later. * Use File.separator consistently * Only export selected api type * Simplify promise polyfill import The behaviour should be the same, according to the es6-promise docs. Previously tsc would report the error: > error TS2307: Cannot find module 'es6-promise'. * Import HttpFile in all models * Export server configurations * Use undefined as default body value The empty string is not interpreted as "no body" by the browser fetch api and thus leads to an exception during get requests * Improve codestyle: prefer guards to nesting * Remove verbose debug output This should not be commited, because every developer has very different requirements what debug information he needs to see. * Fix: Use cleaned model names for imports * Fix: do not call toString on undefined * Fix typo in doc comment * Introduce RequestBody type and remove method check * Support media types other than json (#6177) List of changes: * Add */* as fallback to accept header * Use more sophisticated media type selection * Handle object stringify in ObjectSerializer * Parse response with ObejctSerializer * Fix: Correctly extract response headers in browser * Create HttpFile objects from responses * Handle binary responses * Clean up dependencies and replace isomorphic-fetch Instead of isomorphic-fetch, which is unmaintained, we directly use node-fetch and whatwg-fetch polyfills. * Updated versions in ts-default/jquery and ts docs * Replaced isSuccessCode with is2xx * [TypeScript-Refactor] Use OAIv3 spec and fix bugs in JQuery Blob download (#6416) * Change to OAIv3 spec for TS-Refactor * Moved samples to oaiv3 folder * Updated package-lock * Update pom to use OAIv3 paths for Typescript-refactor * Renamed ts-refactor samples & tests in pom.xmls * Fixed compile issues in ts-refactor jquery http test * Fixed bugs in blob handling of jquery * [Typescript] Support http bearer authentication with token provider (#6425) * Add http bearer security * Update typescript to 3.9 * Fix: Use Authorization header for basic and bearer * Allow asynchronous tokenProvider in bearer auth * Add TS-Rewrite-Jquery tests node_modules to travis caching * Remove NoAuthentication * Added file to generate TS samples on Windows * Exclude btoa in browser * Regen samples * Remove outdated ToDo comments * Document and optimize `getReturnType` in TSClientCodegen * Added option to generate objects for operation function arguments * Upgrade typescript docs * Updated generators * Updated samples * Updated docs * Readded pom.xml * [Typescript] Support InversifyJS (#6489) * Add config option to enable InversifyJS * Add pascal case lambda for mustache * Generate a class for each auth method * Add service identifiers and service binder helper * Split Configuration into interface and factory This way we don't need to import the factory everywhere to do typechecking. * Define minimal interface for ServerConfiguration * Add annotations for inversify when enabled * Always expose list of server configurations * Add samples and defalt tests for useInversify * Simplify sample generation script * Fix: Add object_params arg description to help * Fix: Properly enable inversify with bool property * Build tests in pom instead of prepublish Otherwise running `npm install`, when the build failed was impossible. * Update dependencies for inversify tests * Test basic api service resolution * Remove Promise and Observable prefix from exports * Fix, RxJS: Import Observable in object params api * Add ioc service identifier for object param api * Add hint about unimpeded development * Simplify api service binder syntax * Remove default tests for inversify * Add wrapper for easy promise based http libraries This wrapper allows defining and injecting http libraries that do not need to know anything about observables, especially when useRxJS is not enabled. I will employ this in the tests for InversifyJS. Not sure if we should also use this wrapper internally. * Add named injects for remaining auth parameters * Directly inject promise services without RxJS * Add tests for api service binder * Add convenience method to bind all api services * Fix: Rename inversify test artifact * Run bin/utils/copy-to-website.sh * Restore changes to CONTRIBUTING.md from PR #6489 Co-authored-by: Bodo Graumann <mail@bodograumann.de> Co-authored-by: Esteban Gehring <esteban.gehring@bithost.ch>
9.1 KiB
id | title | sidebar_label |
---|---|---|
contributing | Guidelines For Contributing | Guidelines |
Before submitting an issue
- 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
- Search the open issue and closed issue to ensure no one else has reported something similar before.
- File an issue ticket 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.
- You can also make a suggestion or ask a question by opening an "issue".
Before submitting a PR
- Search the open issue 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" with your suggestion to gather feedback from the community.
- 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. - It's recommended to create a new git branch for the change so that the merge commit message looks nicer in the commit history.
How to contribute
git
If you're new to git, you may find the following FAQs useful:
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 page for more information.
Code generators
All the code generators can be found in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages
If you want to add a new generator, follow the new-generator guide.
Templates
All the templates (mustache) can be found in modules/openapi-generator/src/main/resources.
For a list of variables available in the template, please refer to this page
Style guide
Code change should conform to the programming style guide of the respective languages:
- Ada: https://en.wikibooks.org/wiki/Ada_Style_Guide/Source_Code_Presentation
- Android: https://source.android.com/source/code-style.html
- Bash: https://github.com/bahamas10/bash-style-guide
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
- C++: https://google.github.io/styleguide/cppguide.html
- 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
- 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
- Haskell: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
- Java: https://google.github.io/styleguide/javaguide.html
- JavaScript: https://github.com/airbnb/javascript/
- Kotlin: https://kotlinlang.org/docs/reference/coding-conventions.html
- Groovy: http://groovy-lang.org/style-guide.html
- Go: https://github.com/golang/go/wiki/CodeReviewComments
- ObjC: https://github.com/NYTimes/objective-c-style-guide
- Perl: http://perldoc.perl.org/perlstyle.html
- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md
- PowerShell: https://msdn.microsoft.com/en-us/library/dd878270(v=vs.85).aspx
- Python: https://www.python.org/dev/peps/pep-0008/
- R: https://google.github.io/styleguide/Rguide.xml
- 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 configuration)
- Scala: http://docs.scala-lang.org/style/
- Swift: Apple Developer
- 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, please follow the naming convention below:
- For general vendor extension, use lower case and hyphen. e.g.
x-is-unique
,x-content-type
- 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
- 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.
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
To test the templates, please perform the following:
- Update the Petstore sample by running the shell scripts under
bin
andbin/openapi3
folder. For example, run./bin/python-petstore.sh
and./bin/openapi3/python-petstore.sh
to update the Python PetStore API client undersamples/client/petstore/python
andsamples/openapi3/client/petstore/python
. For Windows, the batch files can be found underbin\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) - During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the
-t
parameter:./bin/python-petstore.sh -t modules/openapi-generator/src/main/resources/python
. - Run the tests in the sample folder using maven
mvn integration-test -rf :<artifactId>
, e.g. open a shell insamples/client/petstore/python
, runmvn integration-test -rf :PythonPetstoreClientTests
. The artifactId of the project can be found in the pom.xml file. (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) - For new test cases, please add to the Fake Petstore spec
To start the CI tests, you can:
- Run
mvn verify -Psamples
, assuming you have all the required tools installed to run tests for different languages. - Leverage http://travis-ci.org to run the CI tests by adding your own openapi-generator repository.
- Run some of the CI tests in your local workspace.
See OpenAPI Tools wiki for more information about the integration tests.
Tips
- Smaller changes are easier to review
- [Optional] For bug fixes, provide a OpenAPI Spec to repeat the issue so that the reviewer can use it to confirm the fix
- 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)
- File a PR with meaningful title, description and commit messages.
- Recommended git settings
git config core.autocrlf input
to tell Git convert CRLF to LF on commit but not the other way around
- 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)