Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Build a UI From a Swagger API
00:00
5 left

Build a UI From a Swagger API

HardPython

Problem

Given a Swagger API, explain how you would build a user interface for it. For this coding exercise, implement build_ui_model to transform a Swagger specification into ordered endpoint models suitable for rendering forms and response information. Preserve path and method order, merge path-level and operation-level parameters, and choose the lowest successful HTTP status. Input is a Swagger-like dictionary; output is a list of operation dictionaries. Use the signature build_ui_model(swagger).

Constraints

  • swagger contains a paths dictionary.
  • Each path value is a dictionary containing HTTP method operations and optionally a parameters list.
  • Each operation contains dictionaries for parameters and responses when those fields are present.
  • There are between 1 and 1,000 paths and at most 2,000 operations.
  • Response keys are numeric HTTP status codes or nonnumeric names such as default.
  • A parameter is identified by its name and in location.

Function Signature

def build_ui_model(swagger):
Interviewer

Your question is Build a UI From a Swagger API. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.