You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2>The ID_MAPPING, DTO_MAPPING and PATH_MAPPING</h2>
702
-
When a custom mappings file is used, the OpenApiLibCore will attempt to import it and then import <code>DTO_MAPPING</code>, <code>PATH_MAPPING</code> and <code>ID_MAPPING</code> from it.
701
+
<h2>The ID_MAPPING, RELATIONS_MAPPING and PATH_MAPPING</h2>
702
+
When a custom mappings file is used, the OpenApiLibCore will attempt to import it and then import <code>RELATIONS_MAPPING</code>, <code>PATH_MAPPING</code> and <code>ID_MAPPING</code> from it.
703
703
For this reason, the exact same name must be used in a custom mappings file (capitilization matters).
704
704
705
705
<h3>The ID_MAPPING</h3>
@@ -721,18 +721,18 @@ <h3>The ID_MAPPING</h3>
721
721
722
722
</code></pre></div>
723
723
724
-
<h3>The DTO_MAPPING</h3>
725
-
The <code>DTO_MAPPING</code> is a dictionary with a tuple as its key and a mappings Dto as its value.
724
+
<h3>The RELATIONS_MAPPING</h3>
725
+
The <code>RELATIONS_MAPPING</code> is a dictionary with a tuple as its key and a RelationsMapping as its value.
726
726
The tuple must be in the form <codeclass="language-python">("path_from_the_paths_section", "method_supported_by_the_path")</code>.
727
727
The <codeclass="language-python">path_from_the_paths_section</code> must be exactly as found in the openapi document.
728
728
The <codeclass="language-python">method_supported_by_the_path</code> must be one of the methods supported by the path and must be in lowercase.
729
729
730
730
<h3>The PATH_MAPPING</h3>
731
-
The <code>PATH_MAPPING</code> is a dictionary with a <code>"path_from_the_paths_section"</code> as its key and a mappings Dto as its value.
731
+
The <code>PATH_MAPPING</code> is a dictionary with a <code>"path_from_the_paths_section"</code> as its key and a RelationsMapping as its value.
732
732
The <code>path_from_the_paths_section</code> must be exactly as found in the openapi document.
733
733
734
734
735
-
<h2>Dto mapping classes</h2>
735
+
<h2>RelationsMapping classes</h2>
736
736
As can be seen from the import section above, a number of classes are available to deal with relations between resources and / or constraints on properties.
737
737
Each of these classes is designed to handle a relation or constraint commonly seen in REST APIs.
To verify that the specified <code>error_code</code> indeed occurs when attempting to <code>delete</code> the Wagegroup, we can implement the following dependency:
To verify that the specified <code>error_code</code> occurs when attempting to <code>post</code> an Employee with an <code>employee_number</code> that is already in use, we can implement the following dependency:
Note how this example reuses the <code>EmployeeDto</code> to model the uniqueness constraint for all the operations (<code>post</code>, <code>put</code> and <code>patch</code>) that all relate to the same <code>employee_number</code>.
856
+
Note how this example reuses the <code>EmployeeMapping</code> to model the uniqueness constraint for all the operations (<code>post</code>, <code>put</code> and <code>patch</code>) that all relate to the same <code>employee_number</code>.
To support additional restrictions like these, the <codeclass="language-python">PropertyValueConstraint</code> supports two additional properties: <codeclass="language-python">error_value</code> and <codeclass="language-python">invalid_value_error_code</code>:
<blockquote><u>Just use this for the <code>path</code></u></blockquote>
951
951
952
952
<blockquote><i>
953
-
Note: The <codeclass="language-python">PathPropertiesConstraint</code> is only applicable to the <codeclass="language-python">get_path_relations</code> in a <codeclass="language-python">Dto</code> and only the <codeclass="language-python">PATH_MAPPING</code> uses the <codeclass="language-python">get_path_relations</code>.
953
+
Note: The <codeclass="language-python">PathPropertiesConstraint</code> is only applicable to the <codeclass="language-python">get_path_relations</code> in a <codeclass="language-python">RelationsMapping</code> and only the <codeclass="language-python">PATH_MAPPING</code> uses the <codeclass="language-python">get_path_relations</code>.
954
954
</i></blockquote>
955
955
956
956
To be able to automatically perform endpoint validations, the OpenApiLibCore has to construct the <code>url</code> for the resource from the <code>path</code> as found in the openapi document.
It should be clear that the OpenApiLibCore won't be able to acquire a valid <code>month</code> and <code>date</code>. The <codeclass="language-python">PathPropertiesConstraint</code> can be used in this case:
To prevent OpenApiLibCore from generating invalid combinations of path and query parameters in this type of endpoint, the <codeclass="language-python">IGNORE</code> special value can be used to ensure the related query parameter is never send in a request.
0 commit comments