Skip to content

Commit

Permalink
Merge branch 'main' into hvam/upd3006
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp authored Sep 11, 2024
2 parents 2ab7e1c + 0c19dac commit 373e2a2
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 10 deletions.
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ We also do not guarantee that every well-documented issue will be fixed.

## Contributing Code
We welcome contributions to our codebase.
Before you start your first contribution, here are some things you should know:

Create [pull requests](https://github.com/SAP/abap-file-formats-tools/compare) if you know exactly what you want to change, and how.
They are most welcome, and may range from minor format corrections to adding whole sections.
Before you start your first contribution, please refer to [the contribution guidelines for SAP open source projects](https://github.com/SAP/.github/blob/main/CONTRIBUTING.md).

## Developer Certificate of Origin (DCO)
Due to legal reasons, contributors will be asked to accept a DCO before they submit the first pull request to this projects, this happens in an automated fashion during the submission process.
Expand Down
2 changes: 1 addition & 1 deletion src/zcl_aff_abap_doc_parser.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ CLASS zcl_aff_abap_doc_parser IMPLEMENTATION.

DATA(string_to_parse) = abap_doc_string.

FIND ALL OCCURRENCES OF PCRE `\$pattern[\s]*(:[\s]*)?'([^']*)'` IN string_to_parse RESULTS DATA(result_table).
FIND ALL OCCURRENCES OF PCRE `\$pattern[\s]*(:[\s]*)?'(\S*)'` IN string_to_parse RESULTS DATA(result_table).

IF lines( result_table ) = 0.
DATA(msg) = parser_log->get_message_text( msgno = 109 msgv1 = CONV #( abap_doc_annotation-pattern ) ).
Expand Down
1 change: 0 additions & 1 deletion src/zcl_aff_abap_doc_parser.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ CLASS ltcl_aff_abap_doc_parser IMPLEMENTATION.
exp_text = |There are several occurrences of annotation { zcl_aff_abap_doc_parser=>abap_doc_annotation-pattern } . First valid is used|
exp_type = zif_aff_log=>c_message_type-info
exp_component_name = `Component Name` ).

ENDMETHOD.

ENDCLASS.
24 changes: 22 additions & 2 deletions src/zcl_aff_test_types.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ CLASS zcl_aff_test_types DEFINITION
END OF struc_link_wrong_type.

TYPES:
"! $pattern '[a-Z]*'
"! $pattern '[a-z]*'
ty_string TYPE string.

TYPES:
Expand All @@ -86,10 +86,30 @@ CLASS zcl_aff_test_types DEFINITION
BEGIN OF string_pattern_simple,
"! <p class="shorttext">String with pattern</p>
"! description
"! $pattern '[a-Z]*'
"! $pattern '[a-z]*'
string_pattern TYPE string,
END OF string_pattern_simple.

TYPES:
"! <p class="shorttext">Structure With Pattern Annotation</p>
"! Structure with pattern annotation
BEGIN OF string_pattern_escape_sequence,
"! <p class="shorttext">String with pattern</p>
"! description
"! $pattern '\n\t\r'
string_pattern TYPE string,
END OF string_pattern_escape_sequence.

TYPES:
"! <p class="shorttext">Structure With Pattern Annotation</p>
"! Structure with pattern annotation
BEGIN OF string_pattern_quotes,
"! <p class="shorttext">String with pattern</p>
"! description
"! $pattern '"\"''
string_pattern TYPE string,
END OF string_pattern_quotes.

TYPES:
"! in ST val(I()) only allow integers
"! $values {@link zcl_aff_test_types.data:co_enum}
Expand Down
2 changes: 2 additions & 0 deletions src/zcl_aff_writer_json_schema.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ CLASS zcl_aff_writer_json_schema IMPLEMENTATION.
ENDIF.
ENDIF.
IF abap_doc-pattern IS NOT INITIAL.
REPLACE ALL OCCURRENCES OF '\' IN abap_doc-pattern WITH '\\'.
REPLACE ALL OCCURRENCES OF '"' IN abap_doc-pattern WITH '\"'.
write_tag( |"pattern": "{ abap_doc-pattern }",| ).
ENDIF.
ENDMETHOD.
Expand Down
60 changes: 57 additions & 3 deletions src/zcl_aff_writer_json_schema.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ CLASS ltcl_json_writer_abap_doc DEFINITION FINAL FOR TESTING
content_media_type_string FOR TESTING RAISING cx_static_check,
encoding_type_next_level FOR TESTING RAISING cx_static_check,
pattern_simple FOR TESTING RAISING cx_static_check,
pattern_complex FOR TESTING RAISING cx_static_check.
pattern_complex FOR TESTING RAISING cx_static_check,
pattern_escape_sequence FOR TESTING RAISING cx_static_check,
pattern_with_quotes FOR TESTING RAISING cx_static_check.

ENDCLASS.

Expand Down Expand Up @@ -2806,7 +2808,7 @@ CLASS ltcl_json_writer_abap_doc IMPLEMENTATION.
( ` "title": "String with pattern",` )
( ` "description": "description",` )
( ` "type": "string", ` )
( ` "pattern": "[a-Z]*" ` )
( ` "pattern": "[a-z]*" ` )
( ` } ` )
( ` }, ` )
( ` "additionalProperties": false ` )
Expand All @@ -2832,7 +2834,59 @@ CLASS ltcl_json_writer_abap_doc IMPLEMENTATION.
( ` "title": "String with pattern",` )
( ` "description": "description",` )
( ` "type": "string", ` )
( ` "pattern": "[a-Z]*" ` )
( ` "pattern": "[a-z]*" ` )
( ` } ` )
( ` }, ` )
( ` "additionalProperties": false ` )
( ` } ` )
( ) ).
zcl_aff_tools_unit_test_helper=>assert_equals_ignore_spaces( act_data = act_schema exp_data = exp_schema ).
log = cut->zif_aff_writer~get_log( ).
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.

METHOD pattern_escape_sequence.
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_escape_sequence( ) ).
DATA(exp_schema) = VALUE string_table(
( ` { ` )
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )
( | "$schema": "{ zcl_aff_writer_json_schema=>c_schema_specification }",| )
( | "$id": "{ schema_id }",| )
( ` "title": "Structure With Pattern Annotation", ` )
( ` "description": "Structure with pattern annotation", ` )
( ` "type": "object", ` )
( ` "properties": { ` )
( ` "stringPattern": { ` )
( ` "title": "String with pattern",` )
( ` "description": "description",` )
( ` "type": "string", ` )
( ` "pattern": "\\n\\t\\r" ` )
( ` } ` )
( ` }, ` )
( ` "additionalProperties": false ` )
( ` } ` )
( ) ).
zcl_aff_tools_unit_test_helper=>assert_equals_ignore_spaces( act_data = act_schema exp_data = exp_schema ).
log = cut->zif_aff_writer~get_log( ).
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.

METHOD pattern_with_quotes.
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_quotes( ) ).
DATA(exp_schema) = VALUE string_table(
( ` { ` )
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )
( | "$schema": "{ zcl_aff_writer_json_schema=>c_schema_specification }",| )
( | "$id": "{ schema_id }",| )
( ` "title": "Structure With Pattern Annotation", ` )
( ` "description": "Structure with pattern annotation", ` )
( ` "type": "object", ` )
( ` "properties": { ` )
( ` "stringPattern": { ` )
( ` "title": "String with pattern",` )
( ` "description": "description",` )
( ` "type": "string", ` )
( ` "pattern": "\"\\\"'" ` )
( ` } ` )
( ` }, ` )
( ` "additionalProperties": false ` )
Expand Down

0 comments on commit 373e2a2

Please sign in to comment.