Skip to content

Commit

Permalink
Update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK committed Sep 12, 2024
1 parent b6f92b9 commit c8cb5ae
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/ballerina-to-oas/spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,26 @@ parameters:
nullable: true
```

The query parameter name in the schema is defaulted to the Ballerina parameter name. But this can be overridden using the `@http:Query` annotation.

```ballerina
service /api on new http:Listener(9090) {
resource function get path(@http:Query{name: "userName"} string param) {
// ...
}
}
```

```yml
parameters:
- name: userName
in: query
required: true
schema:
type: string
```

If the query parameter type is a `map` or `record` with `anydata` fields, then the query parameter schema is wrapped with `content` and `application/json` to indicate that the query parameter should be a JSON object which should be encoded properly.

```ballerina
Expand Down Expand Up @@ -836,6 +856,27 @@ parameters:
nullable: true
```

The header parameter name in the schema is defaulted to the Ballerina parameter name. But this can be overridden using the `@http:Header` annotation.

```ballerina
service /api on new http:Listener(9090) {
resource function get path(@http:Header{name: "xApiKeys"} string[] param) {
// ...
}
}
```

```yml
parameters:
- name: xApiKeys
in: header
schema:
type: array
items:
type: string
```

Additionally, the header parameter can be a closed `record` which contains the above basic types as fields. In that case, each field of this record represents a header parameter.

```ballerina
Expand Down

0 comments on commit c8cb5ae

Please sign in to comment.