cloudflare / cloudflare/chanfana

When using `contentType` for `requestBody` the it is shown Example values (default)

Open
#85 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
766
Forks
70
Avg merge
25m
Merged PRs (30d)
4

Description

When using the following:

```js
const SignUpResponse = {
message: "User Added!"
}

export class SignUp extends OpenAPIRoute {
static schema = {
tags: ["Users"],
summary: "User Sign Up",
requestBody: {
contentType: 'text/plain',
firstname: new Str({
description: "User Firstname",
required: true,
example: "Ashish"
}),
lastname: new Str({
description: "User Lastname",
required: true,
example: "Jullia"
}),
email: new Str({
description: "User Email",
required: true,
example: "username@example.com"
}),
password: new Str({
description: "User Password",
required: true,
example: "As@121212121212"
})
},
responses: {
"200": {
contentType: 'application/json',
schema: {
Response: SignUpResponse,
},
},
},
};

async handle(
request,
env,
context,
data
) {
// Retrieve the validated slug
const { firstname, lastname, email, password } = data.body

// console.log(isValidEmail(email))

return {
message: "User Added!"
};
}
}
```

It shows:
![image](https://github.com/cloudflare/itty-router-openapi/assets/11252951/93fc3230-75ec-45c7-8f23-9f619ec663eb)

![image](https://github.com/cloudflare/itty-router-openapi/assets/11252951/e6370558-ebf6-4f6a-bb92-1361954068f6)

I know I'm missing something but how to correctly pass this `contentType` and where?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.