Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

support AutoRest Extensions for OpenAPI 2.0 #3

Closed
21 tasks done
ctaggart opened this issue Aug 19, 2020 · 4 comments · Fixed by #19
Closed
21 tasks done

support AutoRest Extensions for OpenAPI 2.0 #3

ctaggart opened this issue Aug 19, 2020 · 4 comments · Fixed by #19

Comments

@ctaggart
Copy link
Owner

ctaggart commented Aug 19, 2020

This is a list of the AutoRest Extensions, copied directly from https://github.com/Azure/autorest/blob/master/docs/extensions/readme.md. I've turned it into a todo checklist. The first set of extensions are being added in #2.

Generic Extensions

  • x-ms-code-generation-settings - enables passing code generation settings via OpenAPI definition (deprecated! Please use configuration files instead.)
  • x-ms-skip-url-encoding - skips URL encoding for path and query parameters
  • x-ms-enum - additional metadata for enums
  • x-ms-parameter-grouping - groups method parameters in generated clients
  • x-ms-parameter-location - provides a mechanism to specify that the global parameter is actually a parameter on the operation and not a client property.
  • x-ms-paths - alternative to Paths Object that allows Path Item Object to have query parameters for non pure REST APIs
  • x-ms-client-name - allows control over identifier names used in client-side code generation for parameters and schema properties.
  • x-ms-external - allows specific Definition Objects to be excluded from code generation
  • x-ms-discriminator-value - maps discriminator value on the wire with the definition name.
  • x-ms-client-flatten - flattens client model property or parameter.
  • x-ms-parameterized-host - replaces the fixed host with a host template that can be replaced with variable parameters.
  • x-ms-mutability - provides insight to Autorest on how to generate code. It doesn't alter the modeling of what is actually sent on the wire.
  • x-ms-examples - describes the format for specifying examples for request and response of an operation in an OpenAPI definition.
  • x-ms-error-response - indicates whether the response status code should be treated as an error response
  • (not used) x-ms-text - XML helper for scenario with attributes and text on the same XML node

Microsoft Azure Extensions

  • x-ms-odata - indicates the operation includes one or more OData query parameters.
  • x-ms-pageable - allows paging through lists of data.
  • x-ms-long-running-operation - indicates that the operation implemented Long Running Operation pattern as defined by the Resource Manager API.
  • x-ms-azure-resource - indicates that the Definition Schema Object is a resource as defined by the Resource Manager API
  • x-ms-request-id - allows to overwrite the request id header name
  • x-ms-client-request-id - allows to overwrite the client request id header name
  • x-nullable - when true, specifies that null is a valid value for the associated schema
@rylev
Copy link

rylev commented Sep 25, 2020

These following extensions don't seem to be used in the rest-azure-api-specs repo:

  • (not used) x-ms-text

But these are used in the specs and so we should be able to write tests against them:

  • x-ms-request-id
  • x-ms-paths
  • x-ms-client-name
  • x-ms-discriminator-value
  • x-ms-error-response
  • x-ms-odata
  • x-ms-client-request-id
  • x-nullable

@rylev
Copy link

rylev commented Sep 25, 2020

When testing x-nullable I used "azure-rest-api-specs/specification/batch/data-plane/Microsoft.Batch/stable/2020-09-01.12.0/BatchService.json" which has x-nullable inside a nested schema. The assert_deserialize_without_ignored test still passes even though it must be ignoring that field. In fact, pretty printing the deserialized OpenApi struct, shows that the field is not there (which makes sense since Schema doesn't have that field), but no path from serde_ignored is produced. Perhaps a bug in serde_ignored or perhaps I'm misunderstanding how serde_ignored is supposed to work.

@ctaggart
Copy link
Owner Author

@rylev, thanks for figuring out which extensions are left. I noticed the same thing with serde_ignored last week and didn't get a change to investigate. I looked around and may be assert_json_eq from https://docs.rs/assert-json-diff/1.1.0/assert_json_diff/ or similar will work.

@ctaggart
Copy link
Owner Author

In #18, I added assert_roundtrip_eq which compares the structural diffs. I fixed any issues with to roundtrip the current list of tests specs. That included adding support for x-ms-request-id, x-ms-client-name, x-ms-discriminator-value, x-ms-client-request-id, and x-nullable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants