diff --git a/crates/arc-api/src/server.rs b/crates/arc-api/src/server.rs index 61e409e56..9e2e383f3 100644 --- a/crates/arc-api/src/server.rs +++ b/crates/arc-api/src/server.rs @@ -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 diff --git a/docs/api-reference/arc-api.yaml b/docs/api-reference/arc-api.yaml index f4a0fca61..a316da6fe 100644 --- a/docs/api-reference/arc-api.yaml +++ b/docs/api-reference/arc-api.yaml @@ -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: diff --git a/openapi/arc-api.yaml b/openapi/arc-api.yaml index f4a0fca61..a316da6fe 100644 --- a/openapi/arc-api.yaml +++ b/openapi/arc-api.yaml @@ -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: diff --git a/packages/arc-api-client/src/.openapi-generator/FILES b/packages/arc-api-client/src/.openapi-generator/FILES index 83c35d692..f6834d664 100644 --- a/packages/arc-api-client/src/.openapi-generator/FILES +++ b/packages/arc-api-client/src/.openapi-generator/FILES @@ -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 diff --git a/packages/arc-api-client/src/models/api-question.ts b/packages/arc-api-client/src/models/api-question.ts index 5c9a11243..40a558184 100644 --- a/packages/arc-api-client/src/models/api-question.ts +++ b/packages/arc-api-client/src/models/api-question.ts @@ -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; 'allow_freeform': boolean; } + + diff --git a/packages/arc-api-client/src/models/index.ts b/packages/arc-api-client/src/models/index.ts index 256a71969..13f6952b7 100644 --- a/packages/arc-api-client/src/models/index.ts +++ b/packages/arc-api-client/src/models/index.ts @@ -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'; diff --git a/packages/arc-api-client/src/models/question-type.ts b/packages/arc-api-client/src/models/question-type.ts new file mode 100644 index 000000000..ec488be5b --- /dev/null +++ b/packages/arc-api-client/src/models/question-type.ts @@ -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]; + + +