-
Notifications
You must be signed in to change notification settings - Fork 192
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
[FEATURE REQ] - Export Policy as XML instead of RAWXML #488
Comments
|
By looking at the code I found that the parameter format=rawxml is added in every type involving Policies (ApiOperationPolicy, ApiPolicy, PolicyFragment, ProductPolicy and ServicePolicy). However it is not clear to me how to retrieve a new config setting from DI in the classes that use these records. Will try to do a debug step-by-step to better understand it. |
@Banchio - APIM policies support .NET code within the XML files through policy expressions. Here's an example: <fragment>
<set-header name="x-request-over-limit" exists-action="override">
<value>
@((context.LastError == null) && (int.Parse(context.Request.Headers["Limit"][0]) > 100) ? "Over limit" : "Under limit")
</value>
</set-header>
</fragment> We use @((context.LastError == null) && (int.Parse(context.Request.Headers[\"Limit\"][0]) > 100) ? \"Over limit\" : \"Under limit\") If you want to include an XML parsing step in your pipelines, I would suggest first running the file through a step to escape invalid XML characters, and then parsing the escaped file. |
totally agree that is harder to read but in this format I cannot use Powershell select-xml statement (or anything else that expect a well formatted xml). I tried to replace double quotes within the @( and ) as well as double quotes between @{ and } but gave up on multi-line dotnet code which needed to be escaped. |
Please describe the feature.
After exporting from an existing APIM, it is not always possible to programmatically parse policies files as regular xml because of validation errors.
A possible solution would be to include a flag (both in extractor and publisher) to treat policies as regular xml files and not rawxml, something similar to the OpenApi yaml/json formats basically
The text was updated successfully, but these errors were encountered: