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

[BUG] Failed to Read a $ref If both allOf and properties are Defined #18695

Closed
ChihweiLHBird opened this issue May 17, 2024 · 2 comments
Closed

Comments

@ChihweiLHBird
Copy link

openapi: 3.0.1
info:
  version: 4.176.0
  title: Linode API
servers:
- url: https://api.linode.com/v4
paths:
  /networking/firewalls/{firewallId}/rules:
    parameters:
      - name: firewallId
        in: path
        required: true
        schema:
          type: integer
    put:
      tags:
      - Networking
      summary: Firewall Rules Update
      operationId: updateFirewallRules
      requestBody:
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Firewall/properties/rules'
              type: object
              properties:
                inbound:
                  type: array
                  items:
                    $ref: '#/components/schemas/FirewallRuleConfig'
                outbound:
                  type: array
                  items:
                    $ref: '#/components/schemas/FirewallRuleConfig'
      responses:
        '200':
          description: Firewall Rules updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Firewall/properties/rules'
components:
  schemas:
    Firewall:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        rules:
          type: object
          properties:
            inbound:
              type: array
              items:
                $ref: '#/components/schemas/FirewallRuleConfig'
            outbound:
              type: array
              items:
                $ref: '#/components/schemas/FirewallRuleConfig'
    FirewallRuleConfig:
      type: object
      properties:
        protocol:
          type: string

It failed to read /components/schemas/Firewall/properties/rules and generated an undefined type in Go generator.

[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from rules
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from rules
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from rules
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from rules
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from rules
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from rules
@wing328
Copy link
Member

wing328 commented May 17, 2024

please enable the openapi normalizer rule REFACTOR_ALLOF_WITH_PROPERTIES_ONLY: https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

(in the future, we will default this option/rule to true)

@ChihweiLHBird
Copy link
Author

@wing328 It works, thank you so much! I am closing this issue now.

@ChihweiLHBird ChihweiLHBird changed the title [BUG] Failed to Read a $ref If both allOf properties are Defined [BUG] Failed to Read a $ref If both allOf and properties are Defined May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants