Skip to content

Commit e79e000

Browse files
map serde get_image_fills
1 parent c029bf6 commit e79e000

File tree

7 files changed

+60
-51
lines changed

7 files changed

+60
-51
lines changed

figma_rest_api_file/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "figma-api"
3-
version = "0.31.2"
3+
version = "0.31.3"
44
55
description = "This is the OpenAPI specification for the [Figma REST API](https://www.figma.com/developers/api). Note: we are releasing the OpenAPI specification as a beta given the large surface area and complexity of the REST API. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues)."
66
# Override this license by providing a License Object in the OpenAPI.

figma_rest_api_file/docs/InlineObject3.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**error** | **bool** | For successful requests, this value is always `false`. |
8-
**status** | **f64** | Status code |
97
**meta** | [**models::InlineObject3Meta**](inline_object_3_meta.md) | |
108

119
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

figma_rest_api_file/src/models/inline_object_3.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,15 @@ use serde::{Deserialize, Serialize};
1313

1414
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
1515
pub struct InlineObject3 {
16-
/// For successful requests, this value is always `false`.
17-
#[serde(rename = "error")]
18-
pub error: Error,
19-
/// Status code
20-
#[serde(rename = "status")]
21-
pub status: Status,
2216
#[serde(rename = "meta")]
2317
pub meta: Box<models::InlineObject3Meta>,
2418
}
2519

2620
impl InlineObject3 {
27-
pub fn new(error: Error, status: Status, meta: models::InlineObject3Meta) -> InlineObject3 {
21+
pub fn new(meta: models::InlineObject3Meta) -> InlineObject3 {
2822
InlineObject3 {
29-
error,
30-
status,
3123
meta: Box::new(meta),
3224
}
3325
}
3426
}
35-
/// For successful requests, this value is always `false`.
36-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
37-
pub enum Error {
38-
#[serde(rename = "false")]
39-
False,
40-
}
41-
42-
impl Default for Error {
43-
fn default() -> Error {
44-
Self::False
45-
}
46-
}
47-
/// Status code
48-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
49-
pub enum Status {
50-
#[serde(rename = "200")]
51-
Variant200,
52-
}
53-
54-
impl Default for Status {
55-
fn default() -> Status {
56-
Self::Variant200
57-
}
58-
}
5927

figma_rest_api_file/tests/files_api_integration.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,29 @@ async fn test_get_file() {
2828
result.err()
2929
);
3030
}
31+
32+
#[cfg(feature = "client")]
33+
#[tokio::test]
34+
#[ignore]
35+
async fn test_get_image_fills() {
36+
// Read the Figma API token from the environment variable
37+
38+
use figma_api::apis::files_api::get_image_fills;
39+
let token = env::var("X_FIGMA_TOKEN").expect("X_FIGMA_TOKEN environment variable not set");
40+
let file_key = "kk5VAC0mXblEzdLug3B7fi";
41+
42+
// Create a configuration with the token
43+
let mut config = Configuration::default();
44+
config.api_key = Some(figma_api::apis::configuration::ApiKey {
45+
prefix: None,
46+
key: token,
47+
});
48+
49+
// Call the get_file endpoint
50+
let result = get_image_fills(&config, file_key).await;
51+
assert!(
52+
result.is_ok(),
53+
"get_image_fills request failed: {:?}",
54+
result.err()
55+
);
56+
}

openapi/openapi.file.rust.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5433,17 +5433,6 @@ components:
54335433
schema:
54345434
type: object
54355435
properties:
5436-
error:
5437-
type: boolean
5438-
description: For successful requests, this value is always
5439-
`false`.
5440-
enum:
5441-
- false
5442-
status:
5443-
type: number
5444-
description: Status code
5445-
enum:
5446-
- 200
54475436
meta:
54485437
type: object
54495438
properties:
@@ -5453,15 +5442,11 @@ components:
54535442
fills.
54545443
additionalProperties:
54555444
type: string
5456-
description: A URL to the requested image fill.
54575445
format: uri
54585446
required:
54595447
- images
54605448
required:
5461-
- error
5462-
- status
54635449
- meta
5464-
54655450
GetFileMetaResponse:
54665451
description: Response from the GET /v1/files/{file_key}/meta endpoint.
54675452
content:

openapi/openapi.rust.overrides.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
components:
2+
responses:
3+
GetImageFillsResponse:
4+
description: Response from the GET /v1/files/{file_key}/images endpoint.
5+
content:
6+
application/json:
7+
schema:
8+
type: object
9+
properties:
10+
meta:
11+
type: object
12+
properties:
13+
images:
14+
type: object
15+
description: A map of image references to URLs of the image fills.
16+
additionalProperties:
17+
type: string
18+
format: uri
19+
required:
20+
- images
21+
required:
22+
- meta
223
schemas:
324
HasLayoutTrait:
425
properties:

openapi/rust_rm_type.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
# Set of keys that should be FULLY replaced (not merged) even if both values are dicts
9393
FULL_REPLACE_KEYS = {
94+
"GetImageFillsResponse",
9495
"HasLayoutTrait.properties.layoutGrow", "TextureEffect",
9596
"BaseNoiseEffect", "NoiseEffect",
9697
}
@@ -108,6 +109,7 @@ def deep_merge(a, b, path=""):
108109
else:
109110
deep_merge(a[key], value, full_key)
110111

112+
# Handle components.schemas overrides
111113
for k, v in override_data.get("components", {}).get("schemas", {}).items():
112114
print(f"🔁 Overriding schema: {k}")
113115
if k in FULL_REPLACE_KEYS:
@@ -116,6 +118,15 @@ def deep_merge(a, b, path=""):
116118
base = data["components"]["schemas"].setdefault(k, {})
117119
deep_merge(base, v, k)
118120

121+
# Handle components.responses overrides
122+
for k, v in override_data.get("components", {}).get("responses", {}).items():
123+
print(f"🔁 Overriding response: {k}")
124+
if k in FULL_REPLACE_KEYS:
125+
data["components"]["responses"][k] = v
126+
else:
127+
base = data["components"]["responses"].setdefault(k, {})
128+
deep_merge(base, v, k)
129+
119130

120131
schemas = data["components"]["schemas"]
121132
#

0 commit comments

Comments
 (0)