Skip to content

Local reference parameter required #53

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

Merged
merged 2 commits into from
May 5, 2021
Merged

Local reference parameter required #53

merged 2 commits into from
May 5, 2021

Conversation

keita1714
Copy link
Contributor

Summary

This PR solves the problem that required field for Parameter(LocalReference) is not enabled(always optional: false).

Test Plan

The following yaml is processed correctly.

openapi: 3.0.0
info:
  version: 0.0.1
paths:
  /test:
    get:
      operationId: Test
      parameters:
        - $ref: '#/components/parameters/Requied'
        - $ref: '#/components/parameters/Optional'
components:
  parameters:
    Requied:
      in: query
      name: requied
      description: required parameter
      required: true
      schema:
        type: integer
        format: int32
        example: 1
    Optional:
      in: query
      name: optional
      description: optional parameter
      required: false
      schema:
        type: integer
        format: int32
        example: 2

const name = converterContext.escapePropertySignatureName(localRef.name);
const typeElement = factory.PropertySignature.create({
name: name,
optional: false,
optional: isPathProperty ? false : !localRef.required,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject

Determines whether this parameter is mandatory. If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and its default value is false.

parameter,
context,
converterContext,
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

@Himenon Himenon merged commit ddeeaa8 into Himenon:main May 5, 2021
@Himenon
Copy link
Owner

Himenon commented May 5, 2021

Thanks for the Contribution, @keita1714 ! We have incorporated this fix and released it in v0.9.7.

@keita1714 keita1714 deleted the local-reference-parameter-required branch May 5, 2021 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants