Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions jsapp/js/api/models/importCreateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ The endpoints are grouped by area of intended use. Each category contains relate
*/

export interface ImportCreateRequest {
destination: string
url: string
name?: string
assetUid: string
/** @nullable */
destination?: string | null
/** @nullable */
url?: string | null
/** @nullable */
name?: string | null
/** @nullable */
assetUid?: string | null
/** @nullable */
base64Encoded?: string | null
/** @nullable */
library?: boolean | null
/** @nullable */
desired_type?: string | null
/** @nullable */
totalFiles?: number | null
}
26 changes: 22 additions & 4 deletions jsapp/js/api/react-query/manage-projects-and-library-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1772,12 +1772,30 @@ export const importsCreate = async (
options?: RequestInit,
): Promise<importsCreateResponse> => {
const formData = new FormData()
formData.append(`destination`, importCreateRequest.destination)
formData.append(`url`, importCreateRequest.url)
if (importCreateRequest.name !== undefined) {
if (importCreateRequest.destination !== undefined && importCreateRequest.destination !== null) {
formData.append(`destination`, importCreateRequest.destination)
}
if (importCreateRequest.url !== undefined && importCreateRequest.url !== null) {
formData.append(`url`, importCreateRequest.url)
}
if (importCreateRequest.name !== undefined && importCreateRequest.name !== null) {
formData.append(`name`, importCreateRequest.name)
}
formData.append(`assetUid`, importCreateRequest.assetUid)
if (importCreateRequest.assetUid !== undefined && importCreateRequest.assetUid !== null) {
formData.append(`assetUid`, importCreateRequest.assetUid)
}
if (importCreateRequest.base64Encoded !== undefined && importCreateRequest.base64Encoded !== null) {
formData.append(`base64Encoded`, importCreateRequest.base64Encoded)
}
if (importCreateRequest.library !== undefined && importCreateRequest.library !== null) {
formData.append(`library`, importCreateRequest.library.toString())
}
if (importCreateRequest.desired_type !== undefined && importCreateRequest.desired_type !== null) {
formData.append(`desired_type`, importCreateRequest.desired_type)
}
if (importCreateRequest.totalFiles !== undefined && importCreateRequest.totalFiles !== null) {
formData.append(`totalFiles`, importCreateRequest.totalFiles.toString())
}

return fetchWithAuth<importsCreateResponse>(getImportsCreateUrl(), {
...options,
Expand Down
12 changes: 8 additions & 4 deletions kpi/schema_extensions/v2/imports/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
ImportCreateRequestSerializer = inline_serializer_class(
name='ImportCreateRequestSerializer',
fields={
'destination': serializers.URLField(),
'url': serializers.URLField(),
'name': serializers.CharField(required=False, allow_blank=True),
'assetUid': serializers.CharField(),
'destination': serializers.URLField(required=False, allow_blank=True, allow_null=True),
'url': serializers.URLField(required=False, allow_blank=True, allow_null=True),
'name': serializers.CharField(required=False, allow_blank=True, allow_null=True),
'assetUid': serializers.CharField(required=False, allow_blank=True, allow_null=True),
'base64Encoded': serializers.CharField(required=False, allow_blank=True, allow_null=True),
'library': serializers.BooleanField(required=False, allow_null=True),
'desired_type': serializers.CharField(required=False, allow_blank=True, allow_null=True),
'totalFiles': serializers.IntegerField(required=False, allow_null=True),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Naming inconsistency: snake_case desired_type among camelCase fields

All other fields in this serializer use camelCase (base64Encoded, assetUid, totalFiles), but desired_type remains in snake_case. This inconsistency is now surfaced in the OpenAPI spec and in the generated TypeScript model. The view reads it as request.POST.get('desired_type', None), so the wire name must match — but it's worth confirming whether the intended public API name should be desiredType (camelCase) and the view updated to match, or if the inconsistency is intentional.

@Guitlle Guitlle Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noliveleger I think it'd be the other way around, we'd have to convert the camel case names to snake case because that's how we do it in the rest of the API fields. What do you think? Should we leave it as is?

},
)
Comment thread
Guitlle marked this conversation as resolved.

Expand Down
38 changes: 26 additions & 12 deletions static/openapi/schema_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -11257,8 +11257,7 @@
"$ref": "#/components/schemas/ImportCreateRequest"
}
}
},
"required": true
}
},
"security": [
{
Expand Down Expand Up @@ -25125,24 +25124,39 @@
"properties": {
"destination": {
"type": "string",
"format": "uri"
"format": "uri",
"nullable": true
},
"url": {
"type": "string",
"format": "uri"
"format": "uri",
"nullable": true
},
"name": {
"type": "string"
"type": "string",
"nullable": true
},
"assetUid": {
"type": "string"
"type": "string",
"nullable": true
},
"base64Encoded": {
"type": "string",
"nullable": true
},
"library": {
"type": "boolean",
"nullable": true
},
"desired_type": {
"type": "string",
"nullable": true
},
"totalFiles": {
"type": "integer",
"nullable": true
}
},
"required": [
"assetUid",
"destination",
"url"
]
}
},
"ImportCreateResponse": {
"type": "object",
Expand Down
21 changes: 16 additions & 5 deletions static/openapi/schema_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8228,7 +8228,6 @@ paths:
multipart/form-data:
schema:
$ref: '#/components/schemas/ImportCreateRequest'
required: true
security:
- BasicAuth: []
- TokenAuth: []
Expand Down Expand Up @@ -17892,17 +17891,29 @@ components:
destination:
type: string
format: uri
nullable: true
url:
type: string
format: uri
nullable: true
name:
type: string
nullable: true
assetUid:
type: string
required:
- assetUid
- destination
- url
nullable: true
base64Encoded:
type: string
nullable: true
library:
type: boolean
nullable: true
desired_type:
type: string
nullable: true
totalFiles:
type: integer
nullable: true
ImportCreateResponse:
type: object
properties:
Expand Down
Loading