Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(messages): added custom media type #139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions go/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ type PickleTag struct {
}

type Source struct {
Uri string `json:"uri"`
Data string `json:"data"`
MediaType SourceMediaType `json:"mediaType"`
Uri string `json:"uri"`
Data string `json:"data"`
MediaType string `json:"mediaType"`
}

type SourceReference struct {
Expand Down Expand Up @@ -413,24 +413,6 @@ func (e PickleStepType) String() string {
}
}

type SourceMediaType string

const (
SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_PLAIN SourceMediaType = "text/x.cucumber.gherkin+plain"
SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN SourceMediaType = "text/x.cucumber.gherkin+markdown"
)

func (e SourceMediaType) String() string {
switch e {
case SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_PLAIN:
return "text/x.cucumber.gherkin+plain"
case SourceMediaType_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN:
return "text/x.cucumber.gherkin+markdown"
default:
panic("Bad enum value for SourceMediaType")
}
}

type StepDefinitionPatternType string

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
public final class Source {
private final String uri;
private final String data;
private final SourceMediaType mediaType;
private final String mediaType;

public Source(
String uri,
String data,
SourceMediaType mediaType
String mediaType
) {
this.uri = requireNonNull(uri, "Source.uri cannot be null");
this.data = requireNonNull(data, "Source.data cannot be null");
Expand All @@ -51,7 +51,7 @@ public String getData() {
* The media type of the file. Can be used to specify custom types, such as
* text/x.cucumber.gherkin+plain
*/
public SourceMediaType getMediaType() {
public String getMediaType() {
return mediaType;
}

Expand Down

This file was deleted.

7 changes: 1 addition & 6 deletions javascript/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class Source {

data: string = ''

mediaType: SourceMediaType = SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN
mediaType: string = ''
}

export class SourceReference {
Expand Down Expand Up @@ -677,11 +677,6 @@ export enum PickleStepType {
OUTCOME = 'Outcome',
}

export enum SourceMediaType {
TEXT_X_CUCUMBER_GHERKIN_PLAIN = 'text/x.cucumber.gherkin+plain',
TEXT_X_CUCUMBER_GHERKIN_MARKDOWN = 'text/x.cucumber.gherkin+markdown',
}

export enum StepDefinitionPatternType {
CUCUMBER_EXPRESSION = 'CUCUMBER_EXPRESSION',
REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',
Expand Down
6 changes: 1 addition & 5 deletions jsonschema/Source.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
},
"mediaType": {
"description": "The media type of the file. Can be used to specify custom types, such as\n text/x.cucumber.gherkin+plain",
"type": "string",
"enum": [
"text/x.cucumber.gherkin+plain",
"text/x.cucumber.gherkin+markdown"
]
"type": "string"
}
},
"type": "object"
Expand Down
10 changes: 1 addition & 9 deletions messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ will only have one of its fields set, which indicates the payload of the message
| ----- | ---- | ----------- | ----------- |
| `uri` | string | yes | |
| `data` | string | yes | |
| `mediaType` | [SourceMediaType](#sourcemediatype) | yes | |
| `mediaType` | string | yes | |

## SourceReference

Expand Down Expand Up @@ -502,14 +502,6 @@ One of the following:
* `"Outcome"`


## SourceMediaType

One of the following:

* `"text/x.cucumber.gherkin+plain"`
* `"text/x.cucumber.gherkin+markdown"`


## StepDefinitionPatternType

One of the following:
Expand Down
21 changes: 2 additions & 19 deletions perl/lib/Cucumber/Messages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3236,7 +3236,7 @@ use Scalar::Util qw( blessed );
my %types = (
uri => 'string',
data => 'string',
media_type => '',
media_type => 'string',
);

# This is a work-around for the fact that Moo doesn't have introspection
Expand Down Expand Up @@ -3280,29 +3280,12 @@ has data =>
The media type of the file. Can be used to specify custom types, such as
text/x.cucumber.gherkin+plain


Available constants for valid values of this field:

=over

=item * MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_PLAIN

=item * MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN

=back

=cut


use constant {
MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_PLAIN => 'text/x.cucumber.gherkin+plain',
MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_MARKDOWN => 'text/x.cucumber.gherkin+markdown',
};

has media_type =>
(is => 'ro',
required => 1,
default => sub { MEDIATYPE_TEXT_X_CUCUMBER_GHERKIN_PLAIN },
default => sub { '' },
);


Expand Down
4 changes: 2 additions & 2 deletions php/src-generated/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
* The media type of the file. Can be used to specify custom types, such as
* text/x.cucumber.gherkin+plain
*/
public readonly Source\MediaType $mediaType = Source\MediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN,
public readonly string $mediaType = '',
) {
}

Expand All @@ -61,7 +61,7 @@ public static function fromArray(array $arr): self
return new self(
(string) $arr['uri'],
(string) $arr['data'],
Source\MediaType::from((string) $arr['mediaType']),
(string) $arr['mediaType'],
);
}

Expand Down
15 changes: 0 additions & 15 deletions php/src-generated/Source/MediaType.php

This file was deleted.

7 changes: 1 addition & 6 deletions ruby/lib/cucumber/messages.dtos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ class Source < ::Cucumber::Messages::Message
def initialize(
uri: '',
data: '',
media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN
media_type: ''
)
@uri = uri
@data = data
Expand Down Expand Up @@ -1966,11 +1966,6 @@ class Cucumber::Messages::PickleStepType
OUTCOME = 'Outcome'
end

class Cucumber::Messages::SourceMediaType
TEXT_X_CUCUMBER_GHERKIN_PLAIN = 'text/x.cucumber.gherkin+plain'
TEXT_X_CUCUMBER_GHERKIN_MARKDOWN = 'text/x.cucumber.gherkin+markdown'
end

class Cucumber::Messages::StepDefinitionPatternType
CUCUMBER_EXPRESSION = 'CUCUMBER_EXPRESSION'
REGULAR_EXPRESSION = 'REGULAR_EXPRESSION'
Expand Down