Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
district42 schemas ⇆ JSON Schema
pip3 install schemax
>>> import schemax
>>> from d42 import schema
>>> ExampleSchema = schema.str.len(1, 10)
>>> schemax.to_json_schema(ExampleSchema)
{'type': 'string', 'minLength': 1, 'maxLength': 10}
Also, you could use schemax to translate from JSON-Schema to d42 and generate tests interfaces (in future releases) via command line:
$ schemax translate schema.json
Translation from JSON-Schema to d42-schema for schema.json:
schema.dict({
'number': schema.int.min(1),
optional('street_name'): schema.str,
...: ...
})
schema.json:
{
"type": "object",
"properties": {
"number": { "type": "integer", "minimum": 1 },
"street_name": { "type": "string" }
},
"required": ["number"],
"additionalProperties": true
}
schemax generate my-schema.yml
This command will generate request and response schemas files, API interface and basic scenarios.
You could add basic url to your API as following: --base-url="http://api.example.com"
.
Making your schemas and interfaces more "friendly" could --humanize
flag.
SchemaData
object in codeimport yaml
from schemax import collect_schema_data, SchemaData
from typing import List
# Also could be JSON OpenAPI file
with open('my_openapi.yaml') as schema_file:
raw_schema = yaml.load(schema_file, yaml.FullLoader)
parsed_data: List[SchemaData] = collect_schema_data(raw_schema)
for item in parsed_data:
print(item.path)
print(item.response_schema_d42)
...
All the data is stored in SchemaData object, which has the following fields:
(✅ - done; 🔧 - planned support; ❌ - unsupportable)
(✅ - done; 🔧 - planned support; ❌ - unsupportable)
FAQs
district42 to JSON-Schema translator and vise versa
We found that schemax demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.