-
Notifications
You must be signed in to change notification settings - Fork 5
📝 added documentation for client generation, reformated the head… #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,34 +4,16 @@ The documentation of the API (at least the [backend template](../templates/getti | |||||||
| The OpenAPI definition is generated by scanning the Spring `@Controller`'s, which serve as the Single Source of Truth. | ||||||||
| Thus, the documentation of the API is not saved anywhere permanent inside the codebase and generated on-the-fly only. | ||||||||
|
|
||||||||
| The next sections provide an overview how the documentation is integrated and explains the usage. | ||||||||
|
|
||||||||
| ## Available documentation endpoints | ||||||||
|
|
||||||||
| The OpenAPI documentation is exposed via two endpoints explained below. | ||||||||
| Both endpoints will be dynamically updated based on the current annotations and Javadoc present in the `@Controller` code. | ||||||||
|
|
||||||||
| ### Swagger UI | ||||||||
|
|
||||||||
| The [Swagger UI](https://swagger.io/tools/swagger-ui/) provides a web-based interface for exploring and testing the documented API. | ||||||||
| It is automatically available when using `springdoc-openapi-starter-webmvc-ui` (which is included in the backend template by default) and can be accessed via the following path: | ||||||||
|
|
||||||||
| - `/swagger-ui/index.html` or | ||||||||
| - `/swagger-ui` (shortform) | ||||||||
|
|
||||||||
| This endpoint renders the OpenAPI specification in a user-friendly format and allows direct interaction with all available endpoints. | ||||||||
|
|
||||||||
| ### OpenAPI | ||||||||
|
|
||||||||
| The raw OpenAPI specification is served as machine-readable `.json` and `.yaml`. | ||||||||
| It can be retrieved from the following standard paths: | ||||||||
|
|
||||||||
| - `/v3/api-docs` (`.json`) or | ||||||||
| - `/v3/api-docs.yaml` | ||||||||
|
|
||||||||
| These endpoints are normally used for client generation, validation or export of the documentation as this is a standardized format for any OpenAPI generator. | ||||||||
| The next sections provide an overview how the documentation is integrated and explains the usage. | ||||||||
|
|
||||||||
| ## Generating API definition | ||||||||
| ## Generating OpenAPI definition | ||||||||
|
|
||||||||
| The current API definition can be generated locally as a `.yaml` file using the [Springdoc Maven plugin](https://springdoc.org/#maven-plugin). | ||||||||
|
|
||||||||
|
|
@@ -56,6 +38,71 @@ The OpenAPI `.yaml` file will be saved to the project's target directory with th | |||||||
| Changing the output file location or name via plugin configuration is highly discouraged, as other processes (e.g., client generation) might depend on the default. | ||||||||
| ::: | ||||||||
|
|
||||||||
| ## Generating OpenAPI client | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add blank line above heading. Markdown best practice requires a blank line before headings for proper rendering and linter compliance. 📝 Proposed fix :::
+
## Generating OpenAPI client📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)41-41: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 🤖 Prompt for AI Agents |
||||||||
| The previously generated OpenAPI specification can be used to automatically generate type-safe API clients. | ||||||||
| This is performed via the ``@openapitools/openapi-generator-cli`` and the following npm command: | ||||||||
|
|
||||||||
| ```shell | ||||||||
| npm run api-gen | ||||||||
| ``` | ||||||||
|
|
||||||||
| ::: info Information | ||||||||
| All ``yaml`` files in the folder defined under `glob` will be recognised and used for generating a client. | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove trailing space. Line 50 has a trailing space that should be removed per markdown linting rules. 📝 Proposed fix-All ``yaml`` files in the folder defined under `glob` will be recognised and used for generating a client.
+All ``yaml`` files in the folder defined under `glob` will be recognised and used for generating a client.📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)50-50: Trailing spaces (MD009, no-trailing-spaces) 🤖 Prompt for AI Agents |
||||||||
| Each will have its own destination folder. | ||||||||
| ::: | ||||||||
|
|
||||||||
| The generator is configured via the ``openapitools.json`` file. | ||||||||
| It is possible to add further specifications and generate clients from the same config-file. | ||||||||
| This configuration file supports limited placeholders, which are described [here](https://github.com/OpenAPITools/openapi-generator-cli?tab=readme-ov-file#configuration). | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use descriptive link text instead of "here". The link text "here" is not descriptive. Screen readers and accessibility tools benefit from meaningful link text. 📝 Proposed fix-This configuration file supports limited placeholders, which are described [here](https://github.com/OpenAPITools/openapi-generator-cli?tab=readme-ov-file#configuration).
+This configuration file supports limited placeholders, which are described in the [OpenAPI Generator CLI configuration documentation](https://github.com/OpenAPITools/openapi-generator-cli?tab=readme-ov-file#configuration).📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)56-56: Link text should be descriptive (MD059, descriptive-link-text) 🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
| ```json | ||||||||
| { | ||||||||
| "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", | ||||||||
| "spaces": 2, | ||||||||
| "generator-cli": { | ||||||||
| "version": "7.13.0", | ||||||||
| "generators": { | ||||||||
| "refarch-backend": { | ||||||||
| "generatorName": "typescript-fetch", | ||||||||
| "glob": "../refarch-backend/target/*.yaml", | ||||||||
| "output": "#{cwd}/src/api/#{name}", | ||||||||
| "additionalProperties": { | ||||||||
| "supportsES6": true, | ||||||||
| "enumPropertyNaming": "UPPERCASE", | ||||||||
| "typescriptThreePlus": true | ||||||||
| }, | ||||||||
| "<<yourNameOrVersion>>": { | ||||||||
| "generatorName": "typescript-fetch", | ||||||||
| "glob": "../specLocation/*.yaml", | ||||||||
| "output": "#{cwd}/src/api/#{name}", | ||||||||
| "additionalProperties": { | ||||||||
| "supportsES6": true, | ||||||||
| "enumPropertyNaming": "UPPERCASE", | ||||||||
| "typescriptThreePlus": true | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| ``` | ||||||||
|
Comment on lines
+58
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical JSON structure error in configuration example. The The current structure has 🐛 Proposed fix for JSON structure {
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.13.0",
"generators": {
"refarch-backend": {
"generatorName": "typescript-fetch",
"glob": "../refarch-backend/target/*.yaml",
"output": "#{cwd}/src/api/#{name}",
"additionalProperties": {
"supportsES6": true,
"enumPropertyNaming": "UPPERCASE",
"typescriptThreePlus": true
}
- "<<yourNameOrVersion>>": {
+ },
+ "<<yourNameOrVersion>>": {
"generatorName": "typescript-fetch",
"glob": "../specLocation/*.yaml",
"output": "#{cwd}/src/api/#{name}",
"additionalProperties": {
"supportsES6": true,
"enumPropertyNaming": "UPPERCASE",
"typescriptThreePlus": true
}
}
}
}
}🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
| ## Available documentation endpoints | ||||||||
|
|
||||||||
| The OpenAPI documentation is exposed via two endpoints explained below. | ||||||||
| Both endpoints will be dynamically updated based on the current annotations and Javadoc present in the `@Controller` code. | ||||||||
|
|
||||||||
| ### Swagger UI | ||||||||
|
|
||||||||
| The [Swagger UI](https://swagger.io/tools/swagger-ui/) provides a web-based interface for exploring and testing the documented API. | ||||||||
| It is automatically available when using `springdoc-openapi-starter-webmvc-ui` (which is included in the backend template by default) and can be accessed via the following path: | ||||||||
|
|
||||||||
| - `/swagger-ui/index.html` or | ||||||||
| - `/swagger-ui` (shortform) | ||||||||
|
|
||||||||
| This endpoint renders the OpenAPI specification in a user-friendly format and allows direct interaction with all available endpoints. | ||||||||
|
|
||||||||
|
|
||||||||
| ## Documenting endpoints | ||||||||
|
|
||||||||
| Currently, there are two ways to add documentation to an endpoint. Those will be further explained below. | ||||||||
|
|
@@ -129,3 +176,5 @@ public SomeEntity getEndpoint(@PathVariable("someId") final UUID someId) { | |||||||
| return service.doSth(someId); | ||||||||
| } | ||||||||
| ``` | ||||||||
|
|
||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grammar fix needed.
The phrase "provide an overview how" should be "provide an overview of how" for correct grammar.
📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents