Skip to content

Commit

Permalink
feat(schema): add sortPaths option to sort swagger paths by alphabeti…
Browse files Browse the repository at this point in the history
…cal order

(cherry picked from commit 968aff8)
  • Loading branch information
Romakita committed Oct 25, 2024
1 parent f2a2abf commit 2e73e8c
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 62 deletions.
5 changes: 1 addition & 4 deletions docs/tutorials/swagger.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ The path option for Swagger will be used to expose the documentation:
Ts.ED will print the swagger-ui url in the console.
:::

::: warning
OpenSpec 2 support will be removed in v7.
:::

::: warning
When using helmet, there may be a problem with CSP, to solve this collision, configure the CSP as shown below:

Expand Down Expand Up @@ -105,6 +101,7 @@ Some options are available to configure Swagger-ui, Ts.ED and the default spec i
| operationIdFormatter | `(name: string, propertyKey: string, path: string) => string` | A function to generate the operationId. |
| operationIdPattern | `%c_%m` | A pattern to generate the operationId. Format of operationId field (%c: class name, %m: method name). |
| pathPatterns | `[]` | Include only controllers whose paths match the pattern list provided. |
| sortPaths | `true` | Sort paths by alphabetical order. |

### Multi documentations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`generateSpec() > OS 3.0.1 > should generate spec with sorted paths 1`] = `
{
"info": {
"title": "Api documentation",
"version": "1.0.0",
},
"openapi": "3.0.1",
"paths": {
"/rest/controller1": {
"get": {
"operationId": "controller1Method",
"parameters": [],
"responses": {
"200": {
"description": "Success",
},
},
"tags": [
"Controller1",
],
},
},
"/rest/controller1/test": {
"post": {
"operationId": "controller1Method5",
"parameters": [],
"responses": {
"200": {
"description": "Success",
},
},
"tags": [
"Controller1",
],
},
},
"/rest/controller1/{id}": {
"get": {
"operationId": "controller1MethodById",
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "string",
},
},
],
"responses": {
"200": {
"description": "Success",
},
},
"tags": [
"Controller1",
],
},
},
"/rest/controller2": {
"get": {
"operationId": "controller2Method",
"parameters": [],
"responses": {
"200": {
"description": "Success",
},
},
"tags": [
"Controller2",
],
},
},
"/rest/controller2/{id}": {
"get": {
"operationId": "controller2MethodById",
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "string",
},
},
],
"responses": {
"200": {
"description": "Success",
},
},
"tags": [
"Controller2",
],
},
},
},
"tags": [
{
"name": "Controller2",
},
{
"name": "Controller1",
},
],
}
`;
Loading

0 comments on commit 2e73e8c

Please sign in to comment.