Add QuestionType enum to OpenAPI spec replacing stringly-typed field

The question_type field on ApiQuestion was a bare string serialized via
Debug formatting. Define a proper enum in the spec so typify generates a
typed QuestionType, then map from the workflow enum in the handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-05 00:49:03 -05:00
parent 4f1297572d
commit a40c6bdd29
7 changed files with 68 additions and 8 deletions

View file

@ -24,12 +24,12 @@ use arc_workflows::engine::{RunConfig, WorkflowRunEngine};
use arc_workflows::event::{EventEmitter, WorkflowRunEvent};
use arc_workflows::handler::HandlerRegistry;
use arc_workflows::interviewer::web::WebInterviewer;
use arc_workflows::interviewer::{Answer, Interviewer};
use arc_workflows::interviewer::{Answer, Interviewer, QuestionType};
pub use arc_types::{
ApiQuestion, ApiQuestionOption, PaginatedRunList, PaginationMeta, RunStatus,
RunStatusResponse, StartRunRequest, StartRunResponse, SubmitAnswerRequest,
SubmitAnswerResponse,
ApiQuestion, ApiQuestionOption, PaginatedRunList, PaginationMeta,
QuestionType as ApiQuestionType, RunStatus, RunStatusResponse, StartRunRequest,
StartRunResponse, SubmitAnswerRequest, SubmitAnswerResponse,
};
fn default_page_limit() -> u32 {
@ -668,7 +668,13 @@ async fn get_questions(
.map(|pq| ApiQuestion {
id: pq.id,
text: pq.question.text.clone(),
question_type: format!("{:?}", pq.question.question_type),
question_type: match pq.question.question_type {
QuestionType::YesNo => ApiQuestionType::YesNo,
QuestionType::MultipleChoice => ApiQuestionType::MultipleChoice,
QuestionType::MultiSelect => ApiQuestionType::MultiSelect,
QuestionType::Freeform => ApiQuestionType::Freeform,
QuestionType::Confirmation => ApiQuestionType::Confirmation,
},
options: pq
.question
.options

View file

@ -1305,7 +1305,7 @@ components:
text:
type: string
question_type:
type: string
$ref: "#/components/schemas/QuestionType"
options:
type: array
items:
@ -1313,6 +1313,15 @@ components:
allow_freeform:
type: boolean
QuestionType:
type: string
enum:
- yes_no
- multiple_choice
- multi_select
- freeform
- confirmation
SubmitAnswerRequest:
type: object
required:

View file

@ -1305,7 +1305,7 @@ components:
text:
type: string
question_type:
type: string
$ref: "#/components/schemas/QuestionType"
options:
type: array
items:
@ -1313,6 +1313,15 @@ components:
allow_freeform:
type: boolean
QuestionType:
type: string
enum:
- yes_no
- multiple_choice
- multi_select
- freeform
- confirmation
SubmitAnswerRequest:
type: object
required:

View file

@ -57,6 +57,7 @@ models/pagination-meta.ts
models/preview-url-request.ts
models/preview-url-response.ts
models/project.ts
models/question-type.ts
models/recent-control-result.ts
models/retro-list-item.ts
models/retro-stats.ts

View file

@ -16,12 +16,17 @@
// May contain unused imports in some cases
// @ts-ignore
import type { ApiQuestionOption } from './api-question-option';
// May contain unused imports in some cases
// @ts-ignore
import type { QuestionType } from './question-type';
export interface ApiQuestion {
'id': string;
'text': string;
'question_type': string;
'question_type': QuestionType;
'options': Array<ApiQuestionOption>;
'allow_freeform': boolean;
}

View file

@ -38,6 +38,7 @@ export * from './pagination-meta';
export * from './preview-url-request';
export * from './preview-url-response';
export * from './project';
export * from './question-type';
export * from './recent-control-result';
export * from './retro-list-item';
export * from './retro-stats';

View file

@ -0,0 +1,29 @@
/* tslint:disable */
/* eslint-disable */
/**
* Arc Run API
* HTTP API for managing Arc workflow run executions.
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export const QuestionType = {
YES_NO: 'yes_no',
MULTIPLE_CHOICE: 'multiple_choice',
MULTI_SELECT: 'multi_select',
FREEFORM: 'freeform',
CONFIRMATION: 'confirmation'
} as const;
export type QuestionType = typeof QuestionType[keyof typeof QuestionType];