-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow generating a list of strict operation IDs #2414
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # yaml-language-server: $schema=../../../configuration-schema.json | ||
| package: operationlist | ||
| generate: | ||
| strict-operation-list: true | ||
| output: operation_list.gen.go |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package operationlist | ||
|
|
||
| //go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml spec.yaml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package operationlist | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestStrictOperationIDs(t *testing.T) { | ||
| expected := []string{"ListUsers", "CreateUser", "GetUser", "DeleteUser"} | ||
| assert.ElementsMatch(t, expected, StrictOperationIDs) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| openapi: "3.0.1" | ||
| info: | ||
| version: 1.0.0 | ||
| title: Operation List Test | ||
| paths: | ||
| /users: | ||
| get: | ||
| summary: List users | ||
| operationId: listUsers | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| post: | ||
| summary: Create user | ||
| operationId: createUser | ||
| responses: | ||
| '201': | ||
| description: Created | ||
| /users-alias: | ||
| $ref: "#/paths/~1users" | ||
| /users/{id}: | ||
| get: | ||
| summary: Get user | ||
| operationId: getUser | ||
| parameters: | ||
| - name: id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| delete: | ||
| summary: Delete user | ||
| operationId: deleteUser | ||
| parameters: | ||
| - name: id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '204': | ||
| description: No Content |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // StrictOperationIDs lists the operation name string passed as the second | ||
| // argument to every StrictMiddlewareFunc call. Each entry is the normalized | ||
| // Go identifier for the operation (e.g. "ListUsers"), matching exactly what | ||
| // the strict handler passes when it invokes the middleware chain. | ||
| var StrictOperationIDs = []string{ | ||
|
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.
|
||
| {{- range .OperationIDs}} | ||
| "{{.}}", | ||
| {{- end}} | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.