api-foundry 0.8.10__tar.gz → 0.8.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: api-foundry
3
- Version: 0.8.10
3
+ Version: 0.8.11
4
4
  Summary: The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs
5
5
  Project-URL: Documentation, https://github.com/DanRepik/api-foundry
6
6
  Project-URL: Source, https://github.com/DanRepik/api-foundry
@@ -25,3 +25,4 @@ Requires-Dist: docker; extra == 'dev'
25
25
  Requires-Dist: psycopg2-binary; extra == 'dev'
26
26
  Requires-Dist: pulumi-automation; extra == 'dev'
27
27
  Requires-Dist: pytest>=7.0; extra == 'dev'
28
+ Requires-Dist: simple-oauth-server; extra == 'dev'
@@ -1,5 +1,5 @@
1
1
  # __init__.py
2
- __version__ = "0.8.10"
2
+ __version__ = "0.8.11"
3
3
 
4
4
  from api_foundry.iac.pulumi.api_foundry import APIFoundry
5
5
  from cloud_foundry import logger
@@ -227,17 +227,24 @@ class APISpecEditor:
227
227
  if len(regex_pattern) == 0:
228
228
  regex_pattern = ".*"
229
229
 
230
- return (
230
+ full_pattern = (
231
231
  rf"^{regex_pattern}$"
232
232
  + rf"|^(?:lt::|le::|eq::|ne::|ge::|gt::)?{regex_pattern}$"
233
233
  + rf"|^between::{regex_pattern},{regex_pattern}$"
234
234
  + rf"|^not-between::{regex_pattern},{regex_pattern},"
235
235
  + rf"|^in::{regex_pattern}(,{regex_pattern})*$"
236
236
  + rf"|^not-in::{regex_pattern}(,{regex_pattern})*$"
237
- + r"|^like::.+$"
238
- + r"|^not-like::.+$"
239
237
  )
240
238
 
239
+ # like/not-like only make sense for string-typed properties -- an
240
+ # integer or number property matching "like::123" is meaningless,
241
+ # and unconditionally allowing it let non-string filters through
242
+ # that the SQL layer can't actually execute as a LIKE comparison.
243
+ if property["type"] == "string":
244
+ full_pattern += r"|^like::.+$" + r"|^not-like::.+$"
245
+
246
+ return full_pattern
247
+
241
248
  def generate_query_parameters(self, schema_object: dict[str, Any]):
242
249
  parameters = []
243
250
  for (
@@ -122,7 +122,7 @@ class APIFoundry(ComponentResource):
122
122
  *,
123
123
  api_spec: Union[str, list[str]],
124
124
  batch_path: Optional[str] = None,
125
- secrets: Optional[str] = None,
125
+ secrets: Optional[Union[str, pulumi.Output[str]]] = None,
126
126
  path_prefix: Optional[str] = None,
127
127
  environment: Optional[dict[str, Union[str, pulumi.Output[str]]]] = None,
128
128
  integrations: Optional[list[dict]] = None,
@@ -158,25 +158,38 @@ class APIFoundry(ComponentResource):
158
158
 
159
159
  # Grant read access to referenced secrets
160
160
  if secrets:
161
- try:
162
- secret_arns = list(json.loads(secrets).values())
163
- policy_statements.append(
164
- {
165
- "Effect": "Allow",
166
- "Actions": ["secretsmanager:GetSecretValue"],
167
- "Resources": secret_arns,
168
- }
169
- )
170
- except (json.JSONDecodeError, AttributeError):
171
- # If secrets is an Output or invalid JSON, we can't parse it yet
172
- # Add a broad policy (will be restricted during deployment)
161
+ if isinstance(secrets, pulumi.Output):
162
+ # Resolve the ARNs at deploy time rather than widening the
163
+ # grant to "*". The statement list is resolved as a whole
164
+ # before it reaches cloud_foundry (see below).
173
165
  policy_statements.append(
174
166
  {
175
167
  "Effect": "Allow",
176
168
  "Actions": ["secretsmanager:GetSecretValue"],
177
- "Resources": "*",
169
+ "Resources": secrets.apply(
170
+ lambda s: list(json.loads(s).values())
171
+ ),
178
172
  }
179
173
  )
174
+ else:
175
+ try:
176
+ secret_arns = list(json.loads(secrets).values())
177
+ policy_statements.append(
178
+ {
179
+ "Effect": "Allow",
180
+ "Actions": ["secretsmanager:GetSecretValue"],
181
+ "Resources": secret_arns,
182
+ }
183
+ )
184
+ except (json.JSONDecodeError, AttributeError):
185
+ # Invalid JSON: fall back to a broad policy
186
+ policy_statements.append(
187
+ {
188
+ "Effect": "Allow",
189
+ "Actions": ["secretsmanager:GetSecretValue"],
190
+ "Resources": "*",
191
+ }
192
+ )
180
193
 
181
194
  requirements.extend(
182
195
  [
@@ -212,6 +225,12 @@ class APIFoundry(ComponentResource):
212
225
  if env_vars.get("JWKS_HOST"):
213
226
  requirements.extend(["PyJWT", "cryptography", "requests"])
214
227
 
228
+ if isinstance(secrets, pulumi.Output):
229
+ # cloud_foundry builds the role policy from plain statements, but
230
+ # accepts the statement list itself as an Output. Resolve the
231
+ # list (including Outputs nested in Resources) as one Output.
232
+ policy_statements = pulumi.Output.from_input(policy_statements)
233
+
215
234
  self.api_function = cloud_foundry.python_function(
216
235
  name=name,
217
236
  environment=env_vars,
@@ -677,8 +677,15 @@ class PathOperation(OpenAPIElement):
677
677
  properties[name] = SchemaObjectProperty(self.entity, name, prop_schema)
678
678
  elif section == "parameters":
679
679
  for param in path_operation.get("parameters", {}) or []:
680
+ # OpenAPI parameter objects nest type/default/etc. under
681
+ # `schema` (unlike requestBody/responses properties, which
682
+ # are already flat) -- merge schema over the parameter
683
+ # object so type/default/minLength/etc. are read from the
684
+ # right place while still keeping parameter-level fields
685
+ # like `required` and `description`.
686
+ merged = {**param, **(param.get("schema") or {})}
680
687
  properties[param["name"]] = SchemaObjectProperty(
681
- self.entity, param["name"], param
688
+ self.entity, param["name"], merged
682
689
  )
683
690
  elif section == "responses":
684
691
  responses = path_operation.get("responses", {})
@@ -35,6 +35,9 @@ dev = [
35
35
  "docker",
36
36
  "api_foundry_query_engine",
37
37
  "pulumi-automation",
38
+ # tests/conftest.py imports this directly; was missing here entirely
39
+ # until CI first ran the test suite and caught it.
40
+ "simple-oauth-server",
38
41
  ]
39
42
 
40
43
  [project.urls]
File without changes
File without changes