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

LPS-134123 Hide ObjectEntry in Object APIs and replace it with the entity name #1166

Closed

Conversation

javiergamarra
Copy link

Renaming all appearances of ObjectEntry in the generated OpenAPI. It's not pretty, a lot of code for just hiding an internal concept.

It can also be done with a ModelConverter but those are registered in a singleton and will affect all deployed APIs. The rest of the extension options can not be used in an OSGi world because they require control of instantiation and we can't pass parameters.

Response is now:

openapi: 3.0.1
info:
  title: Object
  version: v1.0
servers:
- url: http://localhost:8080/o/sampleobjectdefinitions/
paths:
  /:
    get:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: flatten
        in: query
        schema:
          type: string
      - name: search
        in: query
        schema:
          type: string
      - name: filter
        in: query
        schema:
          type: string
      - name: page
        in: query
        schema:
          type: string
      - name: pageSize
        in: query
        schema:
          type: string
      - name: sort
        in: query
        schema:
          type: string
      responses:
        default:
          description: default response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PageSampleObjectDefinition'
            application/xml:
              schema:
                $ref: '#/components/schemas/PageSampleObjectDefinition'
    post:
      tags:
      - SampleObjectDefinition
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SampleObjectDefinition'
          application/xml:
            schema:
              $ref: '#/components/schemas/SampleObjectDefinition'
      responses:
        default:
          description: default response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SampleObjectDefinition'
            application/xml:
              schema:
                $ref: '#/components/schemas/SampleObjectDefinition'
  /batch:
    put:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: callbackURL
        in: query
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        default:
          description: default response
          content:
            application/json: {}
    post:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: callbackURL
        in: query
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        default:
          description: default response
          content:
            application/json: {}
    delete:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: callbackURL
        in: query
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        default:
          description: default response
          content:
            application/json: {}
  /openapi.{type}:
    get:
      parameters:
      - name: type
        in: path
        required: true
        schema:
          type: string
      responses:
        default:
          description: default response
          content:
            application/json: {}
            application/yaml: {}
  /{sampleObjectDefinitionId}:
    get:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: sampleObjectDefinitionId
        in: path
        required: true
        schema:
          type: string
      responses:
        default:
          description: default response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SampleObjectDefinition'
            application/xml:
              schema:
                $ref: '#/components/schemas/SampleObjectDefinition'
    put:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: sampleObjectDefinitionId
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SampleObjectDefinition'
          application/xml:
            schema:
              $ref: '#/components/schemas/SampleObjectDefinition'
      responses:
        default:
          description: default response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SampleObjectDefinition'
            application/xml:
              schema:
                $ref: '#/components/schemas/SampleObjectDefinition'
    delete:
      tags:
      - SampleObjectDefinition
      parameters:
      - name: sampleObjectDefinitionId
        in: path
        required: true
        schema:
          type: string
      responses:
        default:
          description: default response
          content:
            application/json: {}
            application/xml: {}
components:
  schemas:
    Creator:
      type: object
      properties:
        additionalName:
          type: string
          description: The author's additional name (e.g., middle name).
          readOnly: true
        contentType:
          type: string
          description: The type of the content.
          readOnly: true
        familyName:
          type: string
          description: The author's surname.
          readOnly: true
        givenName:
          type: string
          description: The author's first name.
          readOnly: true
        id:
          type: integer
          description: The author's ID.
          format: int64
          readOnly: true
        image:
          type: string
          description: A relative URL to the author's profile image.
          readOnly: true
        name:
          type: string
          description: The author's full name.
          readOnly: true
        profileURL:
          type: string
          description: A relative URL to the author's user profile. Optional field,
            can be embedded with nestedFields.
          readOnly: true
        x-class-name:
          type: string
          readOnly: true
          default: com.liferay.headless.delivery.dto.v1_0.Creator
      xml:
        name: Creator
    Facet:
      type: object
      properties:
        facetCriteria:
          type: string
        facetValues:
          type: array
          items:
            $ref: '#/components/schemas/FacetValue'
    FacetValue:
      type: object
      properties:
        numberOfOccurrences:
          type: integer
          format: int32
        term:
          type: string
    PageSampleObjectDefinition:
      type: object
      properties:
        lastPage:
          type: integer
          format: int64
        items:
          type: array
          items:
            $ref: '#/components/schemas/SampleObjectDefinition'
        totalCount:
          type: integer
          format: int64
        pageSize:
          type: integer
          format: int64
        actions:
          type: object
          additionalProperties:
            type: object
            additionalProperties:
              type: string
        page:
          type: integer
          format: int64
        facets:
          type: array
          items:
            $ref: '#/components/schemas/Facet'
    SampleObjectDefinition:
      type: object
      properties:
        actions:
          type: object
          additionalProperties:
            type: object
            additionalProperties:
              type: string
          readOnly: true
        creator:
          $ref: '#/components/schemas/Creator'
        dateCreated:
          type: string
          format: date-time
        dateModified:
          type: string
          format: date-time
        id:
          type: integer
          format: int64
        x-class-name:
          type: string
          readOnly: true
          default: com.liferay.object.rest.dto.v1_0.ObjectEntry
        able:
          type: integer
          format: int64
        baker:
          type: boolean
        dog:
          type: string
          format: date
        easy:
          type: string
        fox:
          type: string
        george:
          type: string
        how:
          type: string
        item:
          type: number
          format: double
        jig:
          type: integer
          format: int32
        king:
          type: object
      xml:
        name: ObjectEntry

XML and className are needed for batch/talend

…tEntry:), parameters (“/objectEntryId”), tags ([“ObjectEntry”]), parameters inside operations (parameters: objectEntry), bodies (content: “#components/ObjectEntry”), responses (“response: ObjectEntry”) and properties (items: ObjectEntry)
@javiergamarra javiergamarra added the s-headless Pull requests to be reviewed by the headless squad label Jun 16, 2021
@liferay-continuous-integration
Copy link
Collaborator

CI is automatically triggering the following test suites:

  •     ci:test:relevant
  •     ci:test:sf

@javiergamarra javiergamarra changed the title LPS-134123 openapi LPS-134123 Hide ObjectEntry in Object APIs and replace it with the entity name Jun 16, 2021
@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:sf - 1 out of 1 jobs passed in 3 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 36c4cececd0f140998d3d81341325b0c01004ca3

Sender Branch:

Branch Name: LPS-134123_openapi
Branch GIT ID: fc8aad1464073c6e22fb7d51e9b91de20f3e2f83

1 out of 1jobs PASSED
1 Successful Jobs:
For more details click here.

@liferay-continuous-integration
Copy link
Collaborator

@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:stable - 10 out of 10 jobs passed

✔️ ci:test:relevant - 22 out of 22 jobs passed in 2 hours 21 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 36c4cececd0f140998d3d81341325b0c01004ca3

Upstream Comparison:

Branch GIT ID: 0a602240c817010ba021c3109da081a00c6af2aa
Jenkins Build URL: Acceptance Upstream DXP (master) #2000

ci:test:stable - 10 out of 10 jobs PASSED
10 Successful Jobs:
ci:test:relevant - 22 out of 22 jobs PASSED
22 Successful Jobs:
For more details click here.
Test bundle downloads:

@liferay-continuous-integration
Copy link
Collaborator

@javierdearcos
Copy link

Good to know that Swagger lib provides mechanisms to modify the method definitions 🙂

@javiergamarra
Copy link
Author

ci:forward

@liferay-continuous-integration
Copy link
Collaborator

CI is automatically triggering the following test suites:

  •     ci:test:relevant
  •     ci:test:sf

The pull request will automatically be forwarded to the user brianchandotcom if the following test suites pass:

  •     ci:test:relevant
  •     ci:test:sf
  •     ci:test:stable

@liferay-continuous-integration
Copy link
Collaborator

Skipping previously passed test suites:
ci:test:relevant
ci:test:sf

@liferay-continuous-integration
Copy link
Collaborator

All required test suite(s) passed.
Forwarding pull request to brianchandotcom.
Console

@liferay-continuous-integration
Copy link
Collaborator

Pull request has been successfully forwarded to brianchandotcom#103304
Console

@javiergamarra javiergamarra deleted the LPS-134123_openapi branch June 18, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants