View | Details | Raw Unified | Return to bug 40433
Collapse All | Expand All

(-)a/api/v1/swagger/definitions/item.yaml (+1 lines)
Lines 162-167 properties: Link Here
162
      - string
162
      - string
163
      - "null"
163
      - "null"
164
    description: Authorized value for the shelving location for this item
164
    description: Authorized value for the shelving location for this item
165
    maxLength: 80
165
  permanent_location:
166
  permanent_location:
166
    type:
167
    type:
167
      - string
168
      - string
(-)a/api/v1/swagger/definitions/library.yaml (+1 lines)
Lines 96-101 properties: Link Here
96
      - string
96
      - string
97
      - "null"
97
      - "null"
98
    description: geolocation of your library
98
    description: geolocation of your library
99
    maxLength: 255
99
  marc_org_code:
100
  marc_org_code:
100
    type:
101
    type:
101
      - string
102
      - string
(-)a/api/v1/swagger/definitions/patron.yaml (+3 lines)
Lines 9-14 properties: Link Here
9
      - string
9
      - string
10
      - "null"
10
      - "null"
11
    description: library assigned user identifier
11
    description: library assigned user identifier
12
    maxLength: 32
12
  surname:
13
  surname:
13
    type:
14
    type:
14
      - string
15
      - string
Lines 241-246 properties: Link Here
241
      - string
242
      - string
242
      - "null"
243
      - "null"
243
    description: patron's login
244
    description: patron's login
245
    maxLength: 75
244
  opac_notes:
246
  opac_notes:
245
    type:
247
    type:
246
      - string
248
      - string
Lines 356-361 properties: Link Here
356
  lang:
358
  lang:
357
    type: string
359
    type: string
358
    description: lang to use to send notices to this patron
360
    description: lang to use to send notices to this patron
361
    maxLength: 25
359
  login_attempts:
362
  login_attempts:
360
    type:
363
    type:
361
      - integer
364
      - integer
(-)a/xt/api.t (-6 / +9 lines)
Lines 220-229 subtest 'maxlength + enum' => sub { Link Here
220
        my $reversed_api_mapping =
220
        my $reversed_api_mapping =
221
            { reverse map { defined $api_mapping->{$_} ? ( $_ => $api_mapping->{$_} ) : () } keys %$api_mapping };
221
            { reverse map { defined $api_mapping->{$_} ? ( $_ => $api_mapping->{$_} ) : () } keys %$api_mapping };
222
222
223
        while ( my ( $attr, $properties ) = each %{ $definition->{properties} } ) {
223
        my $db_columns = $koha_object->_result->columns_info;
224
            my $db_col = $reversed_api_mapping->{$attr};
224
        while ( my ( $db_col, $column_info ) = each %{$db_columns} ) {
225
            next unless $db_col;
225
            my $api_attr   = $api_mapping->{$db_col} || $db_col;
226
            my $column_info = $koha_object->_result->column_info($db_col);
226
            my $properties = $definition->{properties}->{$api_attr};
227
228
            next unless $properties;
229
227
            next unless $column_info->{size};
230
            next unless $column_info->{size};
228
231
229
            next if ref( $column_info->{size} ) eq 'ARRAY';    # decimal # FIXME Could have a test for this as well
232
            next if ref( $column_info->{size} ) eq 'ARRAY';    # decimal # FIXME Could have a test for this as well
Lines 233-239 subtest 'maxlength + enum' => sub { Link Here
233
                ; # FIXME This is not fully correct, we might want to make sure enum is set for both DB and spec. eg. now checkprevcheckout is enum only for the api spec
236
                ; # FIXME This is not fully correct, we might want to make sure enum is set for both DB and spec. eg. now checkprevcheckout is enum only for the api spec
234
237
235
            if ( !exists $properties->{maxLength} || $column_info->{size} != $properties->{maxLength} ) {
238
            if ( !exists $properties->{maxLength} || $column_info->{size} != $properties->{maxLength} ) {
236
                push @failures, sprintf "%s.%s should have maxLength=%s in api spec", $def, $attr, $column_info->{size};
239
                push @failures, sprintf "%s.%s should have maxLength=%s in api spec", $def, $api_attr,
240
                    $column_info->{size};
237
            }
241
            }
238
        }
242
        }
239
        is( scalar(@failures), 0, "maxLength tests for $def" ) or diag Dumper @failures;
243
        is( scalar(@failures), 0, "maxLength tests for $def" ) or diag Dumper @failures;
240
- 

Return to bug 40433