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

Model class with no name breaks common language refiner #70

Closed
darrelmiller opened this issue Apr 5, 2021 · 0 comments · Fixed by #88
Closed

Model class with no name breaks common language refiner #70

darrelmiller opened this issue Apr 5, 2021 · 0 comments · Fixed by #88
Assignees
Labels
fixed type:bug A broken experience
Milestone

Comments

@darrelmiller
Copy link
Member

darrelmiller commented Apr 5, 2021

       protected void MoveClassesWithNamespaceNamesUnderNamespace(CodeElement currentElement) {
            if(currentElement is CodeClass currentClass && 
                currentClass.Parent is CodeNamespace parentNamespace) {
                var childNamespaceWithClassName = parentNamespace.InnerChildElements
                                                                .OfType<CodeNamespace>()
                                                                .FirstOrDefault(x => x.Name
                                                                                    .EndsWith(currentClass.Name, StringComparison.InvariantCultureIgnoreCase));
                if(childNamespaceWithClassName != null) {
                    parentNamespace.InnerChildElements.Remove(currentClass);
                    childNamespaceWithClassName.AddClass(currentClass);
                }
            }
            CrawlTree(currentElement, MoveClassesWithNamespaceNamesUnderNamespace);
        }

CrawlTree will fail with elements that have a null name.

openapi: 3.0.0
info:
  title: "Todo API"
  version: "1.0.0"
paths:
  /todos: 
    get:
      operationId: todos_ListTodos
      parameters:
          - name: active
            in: query
            schema:
              type: boolean
          - name: keyword
            in: query
            schema:
              type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                title: collectionTodos
                type: object
                properties:
                  value:
                    items: 
                      $ref: "#/components/schemas/todo"

    post:
      operationId: todos_CreateTodo
      responses:
        '201':
          description: OK
  /todos/{todoId}:
    get:
      operationId: todos_GetTodo
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/todo"
    delete:
      operationId: todos_DeleteTodo
      responses:
        '200':
          description: OK
  /tag/{tagId}:
    get:
      operationId: todos_GetTag
      responses:
        '200':
          description: OK
components:
  schemas:
    entity:
      type: object
      properties:
        id: 
          type: string
    tag:
      type: object
      properties:
        id: 
          type: string
        displayName: 
          type: string
    todo:
      allOf:
        - $ref: "#/components/schemas/entity"
        - type: object
          properties:
            subject:
              type: string

AB#8849

@baywet baywet added the type:bug A broken experience label Apr 7, 2021
@baywet baywet added this to the Preview milestone Apr 7, 2021
@baywet baywet self-assigned this Apr 8, 2021
@baywet baywet added the fixed label Apr 9, 2021
@baywet baywet closed this as completed in #88 Apr 9, 2021
baywet added a commit that referenced this issue Apr 9, 2021
- fixes #70 a bug where empty class names would make the generation fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed type:bug A broken experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants