You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicated path parameter in a path is deemed invalid #278
As part of triaging an issue raised in oapi-codegen/oapi-codegen#1574 I noticed that vacuum (and therefore libopenapi) seemed to see this as an error, too.
Via the other issue, the spec in question:
openapi: 3.0.3paths:
/admin/realms/{realm}/clients/{client-uuid}/roles/{role-name}/composites/clients/{client-uuid}:
get:
tags:
- Rolessummary: Get client-level roles for the client that are in the role's compositeparameters:
- name: client-uuidin: pathrequired: trueschema:
type: string
- name: role-namein: pathdescription: role's name (not id!)required: trueschema:
type: stringresponses:
"200":
description: OKcontent:
application/json:
schema:
type: arrayitems:
$ref: '#/components/schemas/RoleRepresentation'parameters:
- name: realmin: pathdescription: realm name (not id!)required: trueschema:
type: string
I'm slightly confused; the API doctor rule seems to be covering best practices, but the linked OpenAPI spec doesn't seem to forbid duplicated parameters.
I can understand why this isn't an API best practice -- it introduces unnecessary stutter in the API surface, and leads to the question of what to do when the two instances don't match (presumably, the request is invalid on the server side). On the other hand, this appears to happen in the wild (Keycloak is one example), and other implementations seem to be able to generate clients for this at least.
This isn't a libopenapi issue to be honest, it's a vacuum one. Even then vacuum is a linter, it's not a code generator, it's going to tell you to pay attention to certain things, however that won't prevent the spec from working with other tools that may or may not support that particular function.
The purpose of the tooling is to draw attention to problem areas, because 'in the wild' is just that, anything goes and folks do some crazy stuff with OpenAPI specs. the goal is to help clean things up.
The good news is that all rules can be customized, the levels changed, or disabled completely if they conflict with a pattern you're happy with.
Activity
daveshanley commentedon Apr 25, 2024
Hi Jamie,
This is actually by design. The rule that is triggering this is
path-params(https://quobix.com/vacuum/rules/operations/path-params/)The rule is checking for multiple things, including 'Duplicate parameter names in paths`'
It's not a bug in libopenapi, it's not a bug in vacuum - it's by design.
Also the formatting thing is a known issue, it's marked as a todo in vacuum (https://github.com/daveshanley/vacuum/blob/main/cmd/lint.go#L400)
evankanderson commentedon May 3, 2024
I'm slightly confused; the API doctor rule seems to be covering best practices, but the linked OpenAPI spec doesn't seem to forbid duplicated parameters.
I can understand why this isn't an API best practice -- it introduces unnecessary stutter in the API surface, and leads to the question of what to do when the two instances don't match (presumably, the request is invalid on the server side). On the other hand, this appears to happen in the wild (Keycloak is one example), and other implementations seem to be able to generate clients for this at least.
daveshanley commentedon May 4, 2024
This isn't a
libopenapiissue to be honest, it's avacuumone. Even then vacuum is a linter, it's not a code generator, it's going to tell you to pay attention to certain things, however that won't prevent the spec from working with other tools that may or may not support that particular function.The purpose of the tooling is to draw attention to problem areas, because 'in the wild' is just that, anything goes and folks do some crazy stuff with OpenAPI specs. the goal is to help clean things up.
The good news is that all rules can be customized, the levels changed, or disabled completely if they conflict with a pattern you're happy with.