$ref JSON Pointer tokens are decoded with URLSearchParams: "+" becomes a space and "&" cuts the token
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
- Área
- backend-api-design
Línea de trabajo
Empieza en src/resolver/specmap/lib/refs.js e inspecciona unescapeJsonPointerToken y escapeJsonPointerToken. Lee la regla de decodificación de fragmentos de RFC 6901 citada en la issue y, después, busca las pruebas del resolver para referencias JSON Pointer y añade casos para tokens que contengan +, & y =. La tarea estará terminada cuando esas referencias se resuelvan a las claves exactas sin errores y las pruebas existentes de punteros sigan pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Q&A (please complete the following information)
- OS: Linux (Debian 12)
- Environment: Node.js v26.13.0
- Method of installation: npm
- Swagger-Client version: 3.39.0 (same code on
master841924914d) - Swagger/OpenAPI version: OpenAPI 3.0.3 (and Swagger 2.0; the 3.1 resolver is fine)
Content & configuration
Swagger/OpenAPI definition and Swagger-Client usage, as one script:
import Swagger from "swagger-client";
const spec = {
openapi: "3.0.3",
info: { title: "t", version: "1" },
paths: {
"/a": {
get: {
responses: {
200: {
description: "ok",
content: {
"application/problem+json": {
schema: { type: "object", properties: { title: { type: "string" } } },
},
},
},
},
},
},
"/b": {
get: {
responses: {
200: {
description: "ok",
content: {
"application/json": {
schema: {
$ref: "#/paths/~1a/get/responses/200/content/application~1problem+json/schema",
},
},
},
},
},
},
},
},
};
const r = await Swagger.resolve({ spec });
console.log(r.errors.map((e) => e.message));
for (const [k, alt] of [["x+y", "x y"], ["a&b", "a"], ["q=1&r=2", "q=1"]]) {
const res = await Swagger.resolve({
spec: { a: { [k]: { v: "right" }, [alt]: { v: "WRONG" } }, b: { $ref: "#/a/" + k } },
});
console.log(k, res.spec.b.v, res.errors.length);
}
Describe the bug you're encountering
The specmap resolver decodes JSON Pointer tokens with URLSearchParams, which applies form decoding. A $ref to an application/problem+json media type cannot be resolved, and keys containing +, & or = resolve to a different key.
To reproduce...
Steps to reproduce the behavior:
npm i [email protected]- Run the script above with
node repro.mjs
Output:
[
'Could not resolve reference: #/paths/~1a/get/responses/200/content/application~1problem+json/schema'
]
x+y WRONG 0
a&b WRONG 0
q=1&r=2 WRONG 0
Expected behavior
No errors, and x+y right 0, a&b right 0, q=1&r=2 right 0. In a URI fragment, +, & and = are literal and tokens are only percent-decoded (https://datatracker.ietf.org/doc/html/rfc6901#section-6).
Screenshots
Not applicable.
Additional context or thoughts
unescapeJsonPointerToken / escapeJsonPointerToken in src/resolver/specmap/lib/refs.js use new URLSearchParams(...), which also unescapes ~1/~0 before percent-decoding. decodeURIComponent followed by the ~1/~0 replacement (and the reverse for escaping) would fix it. The current escape and unescape round-trip with each other, so the existing tests do not catch this.
Credit: https://ucsbplse.github.io/
- Lenguaje dominante
- JavaScript
- Estrellas
- 2.7k
- Forks
- 764
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 8
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de swagger-api/swagger-client
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
swagger-api/swagger-client#4318 ·
Los mantenedores suelen responder en 1 día
-
Remove `@scarf/scarf` dependencyAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
swagger-api/swagger-client#4212 · 4 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
swagger-api/swagger-client#4298 · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
swagger-api/swagger-client#4233 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
swagger-api/swagger-client#4223 ·
Los mantenedores suelen responder en 1 día
Todos los issues de swagger-api/swagger-client
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
swc-project/swc-ai-issues#414 ·
-
[workshop-sim] Repair: Make Copilot access and billing path decision self-contained in Steps 07/07dAbiertofeedback simulation workshop
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
githubnext/gh-aw-workshop#5597 ·
Los mantenedores suelen responder en 1 día
-
Add: Film Mania PLAbiertocheck:passed feeds:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Disabled radio toggle button groups lose checked statePosiblemente ocupada @vladosskins178 la tomó hoy. Abiertobug confirmed css has-pr v6
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día