Generation

generate functionMon, 03 Apr 2023

write me a javascript function that parses swagger JSON file and returns all POST endpoints as array of objects with url property and parse the object shape from the #/definitions part and add that as a property named 'obj'

function getPostEndpoints(swagger){ return swagger.paths .filter(p => p.post) .map(p => { return { url: p.path, obj: swagger.definitions[p.post.parameters[0].schema.$ref.replace('#/definitions/', '')] } }) }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant