Skip to content
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

Asana API specs strange naming #364

Open
johnnypea opened this issue Apr 10, 2024 · 2 comments
Open

Asana API specs strange naming #364

johnnypea opened this issue Apr 10, 2024 · 2 comments
Assignees
Labels
enhancement New feature, bug fix, or request

Comments

@johnnypea
Copy link

I noticed strange naming when using Asana API https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_oas.yaml , like "Response78", "Anonymous60", or "Body33". Is this because of the bad specs? Can I do something about it?

[Headers("Accept: application/json")]
[Post("/projects")]
Task<Response78> CreateProject([Query(CollectionFormat.Multi)] IEnumerable<Anonymous60> opt_fields, [Query] bool? opt_pretty, [Body] Body33 body);
@johnnypea johnnypea added the enhancement New feature, bug fix, or request label Apr 10, 2024
@christianhelle
Copy link
Owner

christianhelle commented Apr 11, 2024

Yes, the schema can be improved, or more like simplified

This here:

      responses:
        201:
          description: Successfully created a new allocation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/AllocationResponse'

generates this:

    [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
    public partial class Response5
    {
        [JsonPropertyName("data")]
        public AllocationResponse Data { get; set; }

        private IDictionary<string, object> _additionalProperties;

        [JsonExtensionData]
        public IDictionary<string, object> AdditionalProperties
        {
            get { return _additionalProperties ?? (_additionalProperties = new Dictionary<string, object>()); }
            set { _additionalProperties = value; }
        }
    }

And that could be simplified to something like this:

      responses:
        201:
          description: Successfully created a new allocation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllocationResponse'

so there will be no need to generate an anonymous response wrapper that contains the data property with type AllocationResponse

but if the API itself returns a response like

{
  "data": { }
}

then you can't just change the OpenAPI spec for that API

@christianhelle
Copy link
Owner

The Asana API spec has 30k lines of code so I hope this wasn't written by hand 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, bug fix, or request
Projects
None yet
Development

No branches or pull requests

2 participants