OpenAPITools/openapi-generator

Enum in array of array

Open

#105 aberto em 18 de mai. de 2018

Ver no GitHub
 (5 comments) (0 reactions) (0 assignees)Java (7.516 forks)batch import
Hacktoberfesthelp wanted

Métricas do repositório

Stars
 (26.243 stars)
Métricas de merge de PR
 (Mesclagem média 9d 1h) (123 fundiu PRs em 30d)

Description

The idea of this issue is to extend #66 for other language than java.


There is a high possibility that languages generating inner enums are doing it for “array of enum” but are broken for "array of array of enum” (and more level).

If a mustache template inside {{#vars}}..{{/vars}} is containing something like:

    {{#isEnum}}
    {{^isContainer}}
{{>modelInnerEnum}}
    {{/isContainer}}
    {{/isEnum}}
    {{#items.isEnum}}
      {{#items}}
      {{^isContainer}}
{{>modelInnerEnum}}
      {{/isContainer}}
      {{/items}}
    {{/items.isEnum}}

You should have a look.

I did a search for {{#items.isEnum}}, which give a list of languages: aspnetcore, csharp, csharp-nancyfx, javascript.

Now CodegenProperty.mostInnerItems is available, you should change the mustache code for:

    {{#isEnum}}
    {{^isContainer}}
{{>modelInnerEnum}}
    {{/isContainer}}
    {{#isContainer}}
    {{#mostInnerItems}}
{{>modelInnerEnum}}
    {{/mostInnerItems}}
    {{/isContainer}}
    {{/isEnum}}

Here a OAS2 that can be used:

swagger: '2.0'
info:
  title: Patrocinium
  description: Patrocinium API
  version: 1.0.0
  termsOfService: 'https://www.patrocinium.com/end-user-licensing-agreement/'
  contact:
    name: Patrocinium
    url: 'https://www.patrocinium.com'
    email: support@patrocinium.com
host: papi.patrocinium.com
basePath: /v1
schemes:
  - https
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /db/ActionRole/findAndCountAll:
    post:
      tags:
        - db
      description: Find all instances of ActionRole
      operationId: findActionRole
      parameters:
        - in: body
          name: body
          required: false
          schema:
            $ref: '#/definitions/ActionRoleSearch'
      responses:
        '200':
          description: Successful Operation
        '400':
          description: Bad Request
        '403':
          description: Unauthorized
        '500':
          description: Internal Server Error
definitions:
  ActionRoleSearch:
    type: object
    properties:
      attributes:
        description: A list of the attributes that you want to return.
        type: array
        items:
          type: string
          enum:
            - id
            - actionId
            - roleId
            - createdAt
            - updatedAt
            - deletedAt
      order:
        description: A collection of grouped attribute names and directions.
        type: array
        items:
          type: array
          items:
            type: string
            enum:
              - id
              - actionId
              - roleId
              - createdAt
              - updatedAt
              - deletedAt
              - ASC
              - DESC
      limit:
        description: The number of ActionRole instances to return.
        type: integer
        format: int64
        default: 100
        minimum: 1
        maximum: 1000
      offset:
        description: The number of ActionRole instances to offset the returned rows.
        type: integer
        format: int64
        minimum: 0
        default: 0

You can also look at my OAS3 "tree pots" spec: treepots.yaml


If you have any questions, feel free to ask me here.

Guia do colaborador