$ref JSON Pointer tokens are decoded with URLSearchParams: "+" becomes a space and "&" cuts the token
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
- Ambito
- backend-api-design
Direzione di ricerca
Inizia da src/resolver/specmap/lib/refs.js ed esamina unescapeJsonPointerToken e escapeJsonPointerToken. Leggi la regola di decodifica dei frammenti di RFC 6901 citata nell’issue, poi trova i test del resolver per i riferimenti JSON Pointer e aggiungi casi per i token che contengono +, & e =. Il lavoro è completato quando questi riferimenti vengono risolti nelle chiavi esatte senza errori e i test esistenti dei puntatori continuano a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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/
- Lingua principale
- JavaScript
- Stelle
- 2.7k
- Fork
- 764
- Merge medio
- 1g 10h
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di swagger-api/swagger-client
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
swagger-api/swagger-client#4318 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
swagger-api/swagger-client#4212 · 4 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
swagger-api/swagger-client#4298 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
swagger-api/swagger-client#4233 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
swagger-api/swagger-client#4223 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di swagger-api/swagger-client
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
swc-project/swc-ai-issues#414 ·
-
[workshop-sim] Repair: Make Copilot access and billing path decision self-contained in Steps 07/07dApertafeedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
githubnext/gh-aw-workshop#5597 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Film Mania PLApertacheck:passed feeds:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Disabled radio toggle button groups lose checked stateForse già presa @vladosskins178 l’ha presa oggi. Apertabug confirmed css has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno