-
-
Notifications
You must be signed in to change notification settings - Fork 297
Open
Labels
bug 🔥Broken or incorrect behavior.Broken or incorrect behavior.
Description
Description
This appears to be related to #28:
Problem
When a schema has all properties marked as readOnly or writeOnly, the parser.transforms.readWrite logic only generates a single type instead of splitting into readable/writable variants.
However, if at least one field is neither readOnly nor writeOnly, the generator correctly produces both:
TokenObtainTokenObtainWriteable(or the configured writable name)
Example schema
{
"TokenObtain": {
"type": "object",
"properties": {
"email": { "type": "string", "writeOnly": true },
"password": { "type": "string", "writeOnly": true },
"expires_at": { "type": "integer", "readOnly": true },
"user_id": { "type": "string", "format": "uuid", "readOnly": true },
"refresh_token": { "type": "string", "readOnly": true },
"access_token": { "type": "string", "readOnly": true },
"token_type": { "type": "string", "readOnly": true, "default": "Bearer" }
},
"required": [
"access_token",
"email",
"expires_at",
"password",
"refresh_token",
"token_type",
"user_id"
]
}
}Expected behavior
Even when all fields are read/write scoped, the generator should still split the schema into:
- a readable (response) type
- a writable (request) type
This matches the intent of the fix in #28, but the edge case where no “shared” fields exist still seems to fall through,
Reproducible example or configuration
OpenAPI
{
"openapi": "3.0.3",
"info": {
"title": "readWrite edge case repro",
"version": "1.0.0"
},
"paths": {},
"components": {
"schemas": {
"TokenObtain": {
"type": "object",
"properties": {
"email": { "type": "string", "writeOnly": true },
"password": { "type": "string", "writeOnly": true },
"expires_at": { "type": "integer", "readOnly": true },
"user_id": { "type": "string", "format": "uuid", "readOnly": true },
"refresh_token": { "type": "string", "readOnly": true },
"access_token": { "type": "string", "readOnly": true },
"token_type": { "type": "string", "readOnly": true, "default": "Bearer" }
},
"required": [
"access_token",
"email",
"expires_at",
"password",
"refresh_token",
"token_type",
"user_id"
]
}
}
}
}openapi-ts.config.ts
export default defineConfig({
input: 'openapi.json',
plugins: [
{
name: '@hey-api/client-axios',
parser: {
transforms: {
readWrite: {
requests: '{{name}}Writable',
responses: '{{name}}',
},
},
},
},
],
});
Versions
"@hey-api/client-axios": "^0.9.1",
"@hey-api/openapi-ts": "^0.90.4",
OpenAPI specification (optional)
No response
System information (optional)
No response
Copilot
Metadata
Metadata
Labels
bug 🔥Broken or incorrect behavior.Broken or incorrect behavior.