Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
ChaiJS jsonSchema verifica múltiples tipos

En mi Chai-Test (usándolo para PostMan) quiero validar mi diseño de respuesta API. Para eso he escrito un Chai-Test:

 pm.test("Check response schema", () => { const schema = { "type": "object", "properties": { "success": { "type": "boolean" }, "data": { "type": "object" }, "err": { "type": "object" }, "info": { "type": "string" } }, "required": ["success", "data", "err", "info"] } pm.response.to.have.jsonSchema(schema) })

Mi problema ahora es que los data o el objeto err se definen en función de si la solicitud a la API fue exitosa o no. Quería lograr eso usando dos tipos para los data y el err : objeto Y nulo. Entonces, ¿cómo puedo verificar dos tipos con jsonSchema? ¿O hay otra manera mejor de hacer esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usted puede hacer eso:

 "data": { "type": ["object", "null"] }, "err": { "type": ["object", "null"] }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!