Skip to content

Commit

Permalink
Format rfc7231 map to rfc1123 (#4741)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored May 26, 2023
1 parent 40378f1 commit dca9fe8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@autorest/modelerfour",
"comment": "Map `rfc7231` to `rfc1123` for date-time formats",
"type": "patch"
}
],
"packageName": "@autorest/modelerfour"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@azure-tools/openapi",
"comment": "Add `rfc7231` format",
"type": "minor"
}
],
"packageName": "@azure-tools/openapi"
}
1 change: 1 addition & 0 deletions docs/openapi/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Those formats can be used to specify a more accurate type of data that is sent a
- `time`: A time as defined by ISO 8661
- `date-time`: A Date-Time as defined by date-time - RFC3339
- `date-time-rfc1123`: A Date-Time as defined by date-time - RFC1123
- `date-time-rfc7231`: A Date-Time as defined by date-time - RFC7231
- `duration`: A duration of time
- `password`: A hint to UIs to obscure input.
- `uuid`: Universally Unique Identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class Interpretations {
return value;

case StringFormat.DateTimeRfc1123:
case StringFormat.DateTimeRfc7231:
// return this.parseDateTimeRfc1123Value(value);
return value;

Expand Down
5 changes: 4 additions & 1 deletion packages/extensions/modelerfour/src/modeler/modelerfour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ export class ModelerFour {
example: this.interpret.getExample(schema),
externalDocs: this.interpret.getExternalDocs(schema),
serialization: this.interpret.getSerialization(schema),
format: schema.format === StringFormat.DateTimeRfc1123 ? StringFormat.DateTimeRfc1123 : StringFormat.DateTime,
format:
schema.format === StringFormat.DateTimeRfc1123 || schema.format === StringFormat.DateTimeRfc7231
? StringFormat.DateTimeRfc1123
: StringFormat.DateTime,
}),
);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/libs/openapi/src/v3/formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export enum StringFormat {
/** @description a A Date-Time as defined by date-time - RFC1123 */
DateTimeRfc1123 = "date-time-rfc1123",

/** @description a A Date-Time as defined by date-time - RFC1123 */
DateTimeRfc7231 = "date-time-rfc7231",

/** @description a duration of time (todo: RFC reference? ) */
Duration = "duration",

Expand Down

0 comments on commit dca9fe8

Please sign in to comment.