Skip to content

Commit 25e064a

Browse files
committed
feat(messages): added custom media type
1 parent 5e14259 commit 25e064a

10 files changed

Lines changed: 14 additions & 120 deletions

File tree

go/messages.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ type PickleTag struct {
252252
}
253253

254254
type Source struct {
255-
Uri string `json:"uri"`
256-
Data string `json:"data"`
257-
MediaType SourceMediaType `json:"mediaType"`
255+
Uri string `json:"uri"`
256+
Data string `json:"data"`
257+
MediaType string `json:"mediaType"`
258258
}
259259

260260
type SourceReference struct {
@@ -413,24 +413,6 @@ func (e PickleStepType) String() string {
413413
}
414414
}
415415

416-
type SourceMediaType string
417-
418-
const (
419-
SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_PLAIN SourceMediaType = "text/x.cucumber.gherkin+plain"
420-
SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN SourceMediaType = "text/x.cucumber.gherkin+markdown"
421-
)
422-
423-
func (e SourceMediaType) String() string {
424-
switch e {
425-
case SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_PLAIN:
426-
return "text/x.cucumber.gherkin+plain"
427-
case SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN:
428-
return "text/x.cucumber.gherkin+markdown"
429-
default:
430-
panic("Bad enum value for SourceMediaType")
431-
}
432-
}
433-
434416
type StepDefinitionPatternType string
435417

436418
const (

java/src/generated/java/io/cucumber/messages/types/Source.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
public final class Source {
2121
private final String uri;
2222
private final String data;
23-
private final SourceMediaType mediaType;
23+
private final String mediaType;
2424

2525
public Source(
2626
String uri,
2727
String data,
28-
SourceMediaType mediaType
28+
String mediaType
2929
) {
3030
this.uri = requireNonNull(uri, "Source.uri cannot be null");
3131
this.data = requireNonNull(data, "Source.data cannot be null");
@@ -51,7 +51,7 @@ public String getData() {
5151
* The media type of the file. Can be used to specify custom types, such as
5252
* text/x.cucumber.gherkin+plain
5353
*/
54-
public SourceMediaType getMediaType() {
54+
public String getMediaType() {
5555
return mediaType;
5656
}
5757

java/src/generated/java/io/cucumber/messages/types/SourceMediaType.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

javascript/src/messages.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class Source {
471471

472472
data: string = ''
473473

474-
mediaType: SourceMediaType = SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN
474+
mediaType: string = ''
475475
}
476476

477477
export class SourceReference {
@@ -677,11 +677,6 @@ export enum PickleStepType {
677677
OUTCOME = 'Outcome',
678678
}
679679

680-
export enum SourceMediaType {
681-
TEXT_X_CUCUMBER_GHERKIN_PLAIN = 'text/x.cucumber.gherkin+plain',
682-
TEXT_X_CUCUMBER_GHERKIN_MARKDOWN = 'text/x.cucumber.gherkin+markdown',
683-
}
684-
685680
export enum StepDefinitionPatternType {
686681
CUCUMBER_EXPRESSION = 'CUCUMBER_EXPRESSION',
687682
REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',

jsonschema/Source.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
},
2020
"mediaType": {
2121
"description": "The media type of the file. Can be used to specify custom types, such as\n text/x.cucumber.gherkin+plain",
22-
"type": "string",
23-
"enum": [
24-
"text/x.cucumber.gherkin+plain",
25-
"text/x.cucumber.gherkin+markdown"
26-
]
22+
"type": "string"
2723
}
2824
},
2925
"type": "object"

messages.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ will only have one of its fields set, which indicates the payload of the message
330330
| ----- | ---- | ----------- | ----------- |
331331
| `uri` | string | yes | |
332332
| `data` | string | yes | |
333-
| `mediaType` | [SourceMediaType](#sourcemediatype) | yes | |
333+
| `mediaType` | string | yes | |
334334

335335
## SourceReference
336336

@@ -502,14 +502,6 @@ One of the following:
502502
* `"Outcome"`
503503

504504

505-
## SourceMediaType
506-
507-
One of the following:
508-
509-
* `"text/x.cucumber.gherkin+plain"`
510-
* `"text/x.cucumber.gherkin+markdown"`
511-
512-
513505
## StepDefinitionPatternType
514506

515507
One of the following:

perl/lib/Cucumber/Messages.pm

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,7 +3236,7 @@ use Scalar::Util qw( blessed );
32363236
my %types = (
32373237
uri => 'string',
32383238
data => 'string',
3239-
media_type => '',
3239+
media_type => 'string',
32403240
);
32413241

32423242
# This is a work-around for the fact that Moo doesn't have introspection
@@ -3280,29 +3280,12 @@ has data =>
32803280
The media type of the file. Can be used to specify custom types, such as
32813281
text/x.cucumber.gherkin+plain
32823282
3283-
3284-
Available constants for valid values of this field:
3285-
3286-
=over
3287-
3288-
=item * MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_PLAIN
3289-
3290-
=item * MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN
3291-
3292-
=back
3293-
32943283
=cut
32953284

3296-
3297-
use constant {
3298-
MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_PLAIN => 'text/x.cucumber.gherkin+plain',
3299-
MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN => 'text/x.cucumber.gherkin+markdown',
3300-
};
3301-
33023285
has media_type =>
33033286
(is => 'ro',
33043287
required => 1,
3305-
default => sub { MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_PLAIN },
3288+
default => sub { '' },
33063289
);
33073290

33083291

php/src-generated/Source.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(
4343
* The media type of the file. Can be used to specify custom types, such as
4444
* text/x.cucumber.gherkin+plain
4545
*/
46-
public readonly Source\MediaType $mediaType = Source\MediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN,
46+
public readonly string $mediaType = '',
4747
) {
4848
}
4949

@@ -61,7 +61,7 @@ public static function fromArray(array $arr): self
6161
return new self(
6262
(string) $arr['uri'],
6363
(string) $arr['data'],
64-
Source\MediaType::from((string) $arr['mediaType']),
64+
(string) $arr['mediaType'],
6565
);
6666
}
6767

php/src-generated/Source/MediaType.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

ruby/lib/cucumber/messages.dtos.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ class Source < ::Cucumber::Messages::Message
13721372
def initialize(
13731373
uri: '',
13741374
data: '',
1375-
media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN
1375+
media_type: ''
13761376
)
13771377
@uri = uri
13781378
@data = data
@@ -1966,11 +1966,6 @@ class Cucumber::Messages::PickleStepType
19661966
OUTCOME = 'Outcome'
19671967
end
19681968

1969-
class Cucumber::Messages::SourceMediaType
1970-
TEXT_X_CUCUMBER_GHERKIN_PLAIN = 'text/x.cucumber.gherkin+plain'
1971-
TEXT_X_CUCUMBER_GHERKIN_MARKDOWN = 'text/x.cucumber.gherkin+markdown'
1972-
end
1973-
19741969
class Cucumber::Messages::StepDefinitionPatternType
19751970
CUCUMBER_EXPRESSION = 'CUCUMBER_EXPRESSION'
19761971
REGULAR_EXPRESSION = 'REGULAR_EXPRESSION'

0 commit comments

Comments
 (0)