danielgtaylor / danielgtaylor/apisprout

Add support for readOnly and writeOnly properties

Open
#30 5 comments 0 reactions 0 assignees View on GitHub
bug upstream
Dominant language
Go
Stars
719
Forks
70
PR merge metrics
No merged PRs in 30d

Description

**Summary**
Apisprout does not support `readOnly` and `writeOnly` attributes of properties.

**Steps to reproduce**
Mock this schema:
```yml
paths:
/foo:
get:
operationId: getFoo
responses:
'200':
content:
application/json:
schema:
$ref: "#/components/schemas/fooSchema"
post:
operationId: postFoo
requestBody:
description: The state to set to the alarm
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/fooSchema"

components:
schemas:
fooSchema:
type: object
properties:
normalProp:
type: string
readOnlyProp:
readOnly: true
writeOnlyProp:
writeOnly: true
required:
- normalProp
- readOnlyProp
- writeOnlyProp
```

**Actual result**
In **GET** operation, the example includes `writeOnlyProp`. In **POST** operation it requires `readOnlyProp`.

**Expected result**
1) It shouldn't include `writeOnly` properties in auto-generated examples. The response should be:
```json
{
"normalProp": "string",
"readOnlyProp": "string"
}
```
2) It shouldn't require `readOnly` properties in the request body. This request body should be valid:
```json
{
"normalProp": "foo",
"writeOnlyProp": "bar"
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the YAML reproduction against the GET and POST operations and trace how schema properties are used for generated examples and request validation. Done means GET examples omit writeOnlyProp, while POST validation does not require readOnlyProp and accepts the shown request body.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.